Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
9b86006c
Commit
9b86006c
authored
Jul 15, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/project-export-filename
parents
9c535603
8b7932c2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
26 deletions
+56
-26
CHANGELOG
CHANGELOG
+2
-0
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+10
-0
lib/gitlab/gitlab_import/importer.rb
lib/gitlab/gitlab_import/importer.rb
+28
-25
lib/gitlab/import_export/project_tree_restorer.rb
lib/gitlab/import_export/project_tree_restorer.rb
+4
-1
spec/lib/gitlab/database/migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+4
-0
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+8
-0
No files found.
CHANGELOG
View file @
9b86006c
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.10.0 (unreleased)
v 8.10.0 (unreleased)
- Expose {should,force}_remove_source_branch (Ben Boeckel)
- Expose {should,force}_remove_source_branch (Ben Boeckel)
- Disable PostgreSQL statement timeout during migrations
- Fix projects dropdown loading performance with a simplified api cal. !5113 (tiagonbotelho)
- Fix projects dropdown loading performance with a simplified api cal. !5113 (tiagonbotelho)
- Fix commit builds API, return all builds for all pipelines for given commit. !4849
- Fix commit builds API, return all builds for all pipelines for given commit. !4849
- Replace Haml with Hamlit to make view rendering faster. !3666
- Replace Haml with Hamlit to make view rendering faster. !3666
...
@@ -95,6 +96,7 @@ v 8.10.0 (unreleased)
...
@@ -95,6 +96,7 @@ v 8.10.0 (unreleased)
- Change status color and icon for running builds
- Change status color and icon for running builds
- Fix markdown rendering for: consecutive labels references, label references that begin with a digit or contains `.`
- Fix markdown rendering for: consecutive labels references, label references that begin with a digit or contains `.`
- Project export filename now includes the project and namespace path
- Project export filename now includes the project and namespace path
- Fix last update timestamp on issues not preserved on gitlab.com and project imports
v 8.9.6
v 8.9.6
- Fix importing of events under notes for GitLab projects. !5154
- Fix importing of events under notes for GitLab projects. !5154
...
...
lib/gitlab/database/migration_helpers.rb
View file @
9b86006c
...
@@ -20,11 +20,19 @@ module Gitlab
...
@@ -20,11 +20,19 @@ module Gitlab
if
Database
.
postgresql?
if
Database
.
postgresql?
options
=
options
.
merge
({
algorithm: :concurrently
})
options
=
options
.
merge
({
algorithm: :concurrently
})
disable_statement_timeout
end
end
add_index
(
table_name
,
column_name
,
options
)
add_index
(
table_name
,
column_name
,
options
)
end
end
# Long-running migrations may take more than the timeout allowed by
# the database. Disable the session's statement timeout to ensure
# migrations don't get killed prematurely. (PostgreSQL only)
def
disable_statement_timeout
ActiveRecord
::
Base
.
connection
.
execute
(
'SET statement_timeout TO 0'
)
if
Database
.
postgresql?
end
# Updates the value of a column in batches.
# Updates the value of a column in batches.
#
#
# This method updates the table in batches of 5% of the total row count.
# This method updates the table in batches of 5% of the total row count.
...
@@ -133,6 +141,8 @@ module Gitlab
...
@@ -133,6 +141,8 @@ module Gitlab
'in the body of your migration class'
'in the body of your migration class'
end
end
disable_statement_timeout
transaction
do
transaction
do
add_column
(
table
,
column
,
type
,
default:
nil
)
add_column
(
table
,
column
,
type
,
default:
nil
)
...
...
lib/gitlab/gitlab_import/importer.rb
View file @
9b86006c
...
@@ -15,32 +15,35 @@ module Gitlab
...
@@ -15,32 +15,35 @@ module Gitlab
end
end
def
execute
def
execute
project_identifier
=
CGI
.
escape
(
project
.
import_source
)
ActiveRecord
::
Base
.
no_touching
do
project_identifier
=
CGI
.
escape
(
project
.
import_source
)
# Issues && Comments
issues
=
client
.
issues
(
project_identifier
)
# Issues && Comments
issues
=
client
.
issues
(
project_identifier
)
issues
.
each
do
|
issue
|
body
=
@formatter
.
author_line
(
issue
[
"author"
][
"name"
])
issues
.
each
do
|
issue
|
body
+=
issue
[
"description"
]
body
=
@formatter
.
author_line
(
issue
[
"author"
][
"name"
])
body
+=
issue
[
"description"
]
comments
=
client
.
issue_comments
(
project_identifier
,
issue
[
"id"
])
comments
=
client
.
issue_comments
(
project_identifier
,
issue
[
"id"
])
if
comments
.
any?
body
+=
@formatter
.
comments_header
if
comments
.
any?
body
+=
@formatter
.
comments_header
end
comments
.
each
do
|
comment
|
body
+=
@formatter
.
comment
(
comment
[
"author"
][
"name"
],
comment
[
"created_at"
],
comment
[
"body"
])
end
project
.
issues
.
create!
(
iid:
issue
[
"iid"
],
description:
body
,
title:
issue
[
"title"
],
state:
issue
[
"state"
],
updated_at:
issue
[
"updated_at"
],
author_id:
gl_user_id
(
project
,
issue
[
"author"
][
"id"
])
)
end
end
comments
.
each
do
|
comment
|
body
+=
@formatter
.
comment
(
comment
[
"author"
][
"name"
],
comment
[
"created_at"
],
comment
[
"body"
])
end
project
.
issues
.
create!
(
iid:
issue
[
"iid"
],
description:
body
,
title:
issue
[
"title"
],
state:
issue
[
"state"
],
author_id:
gl_user_id
(
project
,
issue
[
"author"
][
"id"
])
)
end
end
true
true
...
...
lib/gitlab/import_export/project_tree_restorer.rb
View file @
9b86006c
...
@@ -12,7 +12,10 @@ module Gitlab
...
@@ -12,7 +12,10 @@ module Gitlab
json
=
IO
.
read
(
@path
)
json
=
IO
.
read
(
@path
)
@tree_hash
=
ActiveSupport
::
JSON
.
decode
(
json
)
@tree_hash
=
ActiveSupport
::
JSON
.
decode
(
json
)
@project_members
=
@tree_hash
.
delete
(
'project_members'
)
@project_members
=
@tree_hash
.
delete
(
'project_members'
)
create_relations
ActiveRecord
::
Base
.
no_touching
do
create_relations
end
rescue
=>
e
rescue
=>
e
@shared
.
error
(
e
)
@shared
.
error
(
e
)
false
false
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
9b86006c
...
@@ -13,6 +13,10 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
...
@@ -13,6 +13,10 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
context
'outside a transaction'
do
context
'outside a transaction'
do
before
do
before
do
expect
(
model
).
to
receive
(
:transaction_open?
).
and_return
(
false
)
expect
(
model
).
to
receive
(
:transaction_open?
).
and_return
(
false
)
unless
Gitlab
::
Database
.
postgresql?
allow_any_instance_of
(
Gitlab
::
Database
::
MigrationHelpers
).
to
receive
(
:disable_statement_timeout
)
end
end
end
context
'using PostgreSQL'
do
context
'using PostgreSQL'
do
...
...
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
View file @
9b86006c
...
@@ -30,6 +30,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
...
@@ -30,6 +30,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
expect
(
Event
.
where
.
not
(
data:
nil
).
first
.
data
[
:ref
]).
not_to
be_empty
expect
(
Event
.
where
.
not
(
data:
nil
).
first
.
data
[
:ref
]).
not_to
be_empty
end
end
it
'preserves updated_at on issues'
do
restored_project_json
issue
=
Issue
.
where
(
description:
'Aliquam enim illo et possimus.'
).
first
expect
(
issue
.
reload
.
updated_at
.
to_s
).
to
eq
(
'2016-06-14 15:02:47 UTC'
)
end
context
'event at forth level of the tree'
do
context
'event at forth level of the tree'
do
let
(
:event
)
{
Event
.
where
(
title:
'test levels'
).
first
}
let
(
:event
)
{
Event
.
where
(
title:
'test levels'
).
first
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment