BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d8fe2fac
Commit
d8fe2fac
authored
Nov 15, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure we have the branch on the other project
parent
5de74551
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
10 deletions
+21
-10
project.rb
app/models/project.rb
+11
-0
create_branch_service.rb
app/services/create_branch_service.rb
+1
-9
base_service.rb
app/services/files/base_service.rb
+9
-1
No files found.
app/models/project.rb
View file @
d8fe2fac
...
...
@@ -988,6 +988,17 @@ class Project < ActiveRecord::Base
Gitlab
::
UploadsTransfer
.
new
.
rename_project
(
path_was
,
path
,
namespace
.
path
)
end
def
fetch_ref
(
source_project
,
branch_name
,
ref
)
repository
.
fetch_ref
(
source_project
.
repository
.
path_to_repo
,
"refs/heads/
#{
ref
}
"
,
"refs/heads/
#{
branch_name
}
"
)
repository
.
after_create_branch
repository
.
find_branch
(
branch_name
)
end
# Expires various caches before a project is renamed.
def
expire_caches_before_rename
(
old_path
)
repo
=
Repository
.
new
(
old_path
,
self
)
...
...
app/services/create_branch_service.rb
View file @
d8fe2fac
...
...
@@ -7,15 +7,7 @@ class CreateBranchService < BaseService
return
failure
if
failure
new_branch
=
if
source_project
!=
@project
repository
.
fetch_ref
(
source_project
.
repository
.
path_to_repo
,
"refs/heads/
#{
ref
}
"
,
"refs/heads/
#{
branch_name
}
"
)
repository
.
after_create_branch
repository
.
find_branch
(
branch_name
)
@project
.
fetch_ref
(
source_project
,
branch_name
,
ref
)
else
repository
.
add_branch
(
current_user
,
branch_name
,
ref
)
end
...
...
app/services/files/base_service.rb
View file @
d8fe2fac
...
...
@@ -23,7 +23,7 @@ module Files
validate
# Create new branch if it different from source_branch
validat
e_target_branch
if
different_branch?
ensur
e_target_branch
if
different_branch?
result
=
commit
if
result
...
...
@@ -71,6 +71,14 @@ module Files
end
end
def
ensure_target_branch
validate_target_branch
if
@source_project
!=
project
@project
.
fetch_ref
(
@source_project
,
@target_branch
,
@source_branch
)
end
end
def
validate_target_branch
result
=
ValidateNewBranchService
.
new
(
project
,
current_user
).
execute
(
@target_branch
)
...
...
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