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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
ceff0c91
Commit
ceff0c91
authored
Aug 02, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check out locally PRs where the source/target branch were removed
parent
1aba0668
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
lib/gitlab/github_import/importer.rb
lib/gitlab/github_import/importer.rb
+11
-7
No files found.
lib/gitlab/github_import/importer.rb
View file @
ceff0c91
...
...
@@ -71,11 +71,12 @@ module Gitlab
pull_requests
=
client
.
pull_requests
(
repo
,
state: :all
,
sort: :created
,
direction: :asc
,
per_page:
100
)
pull_requests
=
pull_requests
.
map
{
|
raw
|
PullRequestFormatter
.
new
(
project
,
raw
)
}.
select
(
&
:valid?
)
source_branches_removed
=
pull_requests
.
reject
(
&
:source_branch_exists?
).
map
{
|
pr
|
[
pr
.
source_branch_name
,
pr
.
source_branch_sha
]
}
source_branches_removed
=
pull_requests
.
reject
(
&
:source_branch_exists?
).
map
{
|
pr
|
[
pr
.
source_branch_name
,
pr
.
number
]
}
target_branches_removed
=
pull_requests
.
reject
(
&
:target_branch_exists?
).
map
{
|
pr
|
[
pr
.
target_branch_name
,
pr
.
target_branch_sha
]
}
branches_removed
=
source_branches_removed
|
target_branches_removed
restore_branches
(
branches_removed
)
restore_source_branches
(
source_branches_removed
)
restore_target_branches
(
target_branches_removed
)
pull_requests
.
each
do
|
pull_request
|
merge_request
=
pull_request
.
create!
...
...
@@ -120,17 +121,20 @@ module Gitlab
end
end
def
restore_branches
(
branches
)
branches
.
each
do
|
name
,
sha
|
client
.
create_ref
(
repo
,
"refs/heads/
#{
name
}
"
,
sha
)
def
restore_
source_
branches
(
branches
)
branches
.
each
do
|
name
,
number
|
project
.
repository
.
fetch_ref
(
repo_url
,
"pull/
#{
number
}
/head"
,
name
)
end
end
project
.
repository
.
fetch_ref
(
repo_url
,
'+refs/heads/*'
,
'refs/heads/*'
)
def
restore_target_branches
(
branches
)
branches
.
each
do
|
name
,
sha
|
project
.
repository
.
create_branch
(
name
,
sha
)
end
end
def
clean_up_restored_branches
(
branches
)
branches
.
each
do
|
name
,
_
|
client
.
delete_ref
(
repo
,
"heads/
#{
name
}
"
)
project
.
repository
.
delete_branch
(
name
)
rescue
Rugged
::
ReferenceError
end
...
...
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