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
eddee5fe
Commit
eddee5fe
authored
Nov 15, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure we create target branch for cherry/revert
parent
30d7b5c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
app/models/repository.rb
app/models/repository.rb
+10
-7
No files found.
app/models/repository.rb
View file @
eddee5fe
...
...
@@ -988,7 +988,8 @@ class Repository
end
def
revert
(
user
,
commit
,
base_branch
,
revert_tree_id
=
nil
)
source_sha
=
find_branch
(
base_branch
).
dereferenced_target
.
sha
source_sha
=
raw_ensure_branch
(
base_branch
,
source_commit:
commit
).
first
.
dereferenced_target
.
sha
revert_tree_id
||=
check_revert_content
(
commit
,
base_branch
)
return
false
unless
revert_tree_id
...
...
@@ -1008,7 +1009,8 @@ class Repository
end
def
cherry_pick
(
user
,
commit
,
base_branch
,
cherry_pick_tree_id
=
nil
)
source_sha
=
find_branch
(
base_branch
).
dereferenced_target
.
sha
source_sha
=
raw_ensure_branch
(
base_branch
,
source_commit:
commit
).
first
.
dereferenced_target
.
sha
cherry_pick_tree_id
||=
check_cherry_pick_content
(
commit
,
base_branch
)
return
false
unless
cherry_pick_tree_id
...
...
@@ -1118,7 +1120,8 @@ class Repository
update_autocrlf_option
ref
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
branch
target_branch
,
new_branch_added
=
raw_ensure_branch
(
branch
,
source_branch
)
target_branch
,
new_branch_added
=
raw_ensure_branch
(
branch
,
source_branch:
source_branch
)
was_empty
=
empty?
# Make commit
...
...
@@ -1200,19 +1203,19 @@ class Repository
Gitlab
::
Metrics
.
add_event
(
event
,
{
path:
path_with_namespace
}.
merge
(
tags
))
end
def
raw_ensure_branch
(
branch_name
,
source_
branch
)
def
raw_ensure_branch
(
branch_name
,
source_
commit:
nil
,
source_branch:
nil
)
old_branch
=
find_branch
(
branch_name
)
if
old_branch
[
old_branch
,
false
]
elsif
source_branch
elsif
source_
commit
||
source_
branch
oldrev
=
Gitlab
::
Git
::
BLANK_SHA
ref
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
branch_name
target
=
commit
(
source_branch
).
try
(
:id
)
target
=
(
source_commit
||
commit
(
source_branch
)).
try
(
:sha
)
unless
target
raise
CommitError
.
new
(
"Cannot find branch
#{
branch_name
}
nor
#{
source_branch
}
"
)
"Cannot find branch
#{
branch_name
}
nor
#{
source_
commit
.
try
(
:sha
)
||
source_
branch
}
"
)
end
update_ref!
(
ref
,
target
,
oldrev
)
...
...
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