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
c0f92160
Commit
c0f92160
authored
Aug 17, 2017
by
Saverio Miroddi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct the cherry-pick message for merge commits
The list of commits must be generated from the merge request, not from a diff of the branches.
parent
919c0c7b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
23 deletions
+45
-23
commit.rb
app/models/commit.rb
+7
-10
repository.rb
app/models/repository.rb
+1
-3
commit_spec.rb
spec/models/commit_spec.rb
+35
-8
commits_spec.rb
spec/requests/api/commits_spec.rb
+1
-1
commits_spec.rb
spec/requests/api/v3/commits_spec.rb
+1
-1
No files found.
app/models/commit.rb
View file @
c0f92160
...
...
@@ -251,19 +251,16 @@ class Commit
project
.
repository
.
next_branch
(
"cherry-pick-
#{
short_id
}
"
,
mild:
true
)
end
def
cherry_pick_description
(
start_project
,
start_branch_name
)
def
cherry_pick_description
(
user
)
message_buffer
=
"(cherry picked from commit
#{
sha
}
)"
if
merge_commit?
compare
=
CompareService
.
new
(
project
,
sha
).
execute
(
start_project
,
start_branch_name
)
# Ignore the merge commit.
commits_in_merge
=
compare
.
commits
[
0
..-
2
]
if
merged_merge_request?
(
user
)
commits_in_merge_request
=
merged_merge_request
(
user
).
commits
if
commits_in_merge
.
present?
if
commits_in_merge
_request
.
present?
message_buffer
<<
"
\n
"
commits_in_merge
.
each
do
|
commit_in_merge
|
commits_in_merge
_request
.
each
do
|
commit_in_merge
|
message_buffer
<<
"
\n
#{
commit_in_merge
.
short_id
}
#{
commit_in_merge
.
title
}
"
end
end
...
...
@@ -272,8 +269,8 @@ class Commit
message_buffer
end
def
cherry_pick_message
(
start_project
,
start_branch_name
)
%Q{
#{
message
}
\n\n
#{
cherry_pick_description
(
start_project
,
start_branch_name
)
}
}
def
cherry_pick_message
(
user
)
%Q{
#{
message
}
\n\n
#{
cherry_pick_description
(
user
)
}
}
end
def
revert_description
(
user
)
...
...
app/models/repository.rb
View file @
c0f92160
...
...
@@ -879,9 +879,7 @@ class Repository
committer
=
user_to_committer
(
user
)
commit_message
=
commit
.
cherry_pick_message
(
start_project
,
start_branch_name
)
create_commit
(
message:
commit_message
,
create_commit
(
message:
commit
.
cherry_pick_message
(
user
),
author:
{
email:
commit
.
author_email
,
name:
commit
.
author_name
,
...
...
spec/models/commit_spec.rb
View file @
c0f92160
...
...
@@ -196,25 +196,52 @@ eos
end
describe
'#cherry_pick_message'
do
let
(
:regular_commit
)
{
project
.
commit
(
'video'
)
}
let
(
:merge_commit
)
{
project
.
commit
(
'wip'
)
}
let
(
:user
)
{
create
(
:user
)
}
context
'of a regular commit'
do
it
{
expect
(
regular_commit
.
cherry_pick_message
(
project
,
'master'
)).
to
include
(
"
\n\n
(cherry picked from commit 88790590ed1337ab189bccaa355f068481c90bec)"
)
}
let
(
:commit
)
{
project
.
commit
(
'video'
)
}
it
{
expect
(
commit
.
cherry_pick_message
(
user
)).
to
include
(
"
\n\n
(cherry picked from commit 88790590ed1337ab189bccaa355f068481c90bec)"
)
}
end
context
'of a merge commit'
do
let
(
:repository
)
{
project
.
repository
}
let
(
:commit_options
)
do
author
=
repository
.
user_to_committer
(
user
)
commit_options
=
{
message:
'Test message'
,
committer:
author
,
author:
author
}
end
let
(
:merge_commit
)
do
merge_request
=
create
(
:merge_request
,
source_branch:
'feature'
,
target_branch:
'master'
,
source_project:
project
,
author:
user
)
merge_commit_id
=
repository
.
merge
(
user
,
merge_request
.
diff_head_sha
,
merge_request
,
commit_options
)
merge_commit
=
repository
.
commit
(
merge_commit_id
)
# Manually mark as completed.
#
merge_request
.
update
(
merge_commit_sha:
merge_commit_id
)
merge_commit
end
it
do
expected_appended_text
=
<<~
STR
.
rstrip
(cherry picked from commit
#{
merge_commit
.
sha
}
)
(cherry picked from commit b9238ee5bf1d7359dd3b8c89fd76c1c7f8b75aba)
6d664995 This commit will be fixupped against
64117577 fixup! This commit will be fixupped against
0b4bc9a4 Feature added
STR
expect
(
merge_commit
.
cherry_pick_message
(
project
,
'master'
)).
to
include
(
expected_appended_text
)
expect
(
merge_commit
.
cherry_pick_message
(
user
)).
to
include
(
expected_appended_text
)
end
end
end
...
...
spec/requests/api/commits_spec.rb
View file @
c0f92160
...
...
@@ -791,7 +791,7 @@ describe API::Commits do
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/commit/basic'
)
expect
(
json_response
[
'title'
]).
to
eq
(
commit
.
title
)
expect
(
json_response
[
'message'
]).
to
eq
(
commit
.
cherry_pick_message
(
project
,
branch
))
expect
(
json_response
[
'message'
]).
to
eq
(
commit
.
cherry_pick_message
(
user
))
expect
(
json_response
[
'author_name'
]).
to
eq
(
commit
.
author_name
)
expect
(
json_response
[
'committer_name'
]).
to
eq
(
user
.
name
)
end
...
...
spec/requests/api/v3/commits_spec.rb
View file @
c0f92160
...
...
@@ -474,7 +474,7 @@ describe API::V3::Commits do
expect
(
response
).
to
have_http_status
(
201
)
expect
(
json_response
[
'title'
]).
to
eq
(
master_pickable_commit
.
title
)
expect
(
json_response
[
'message'
]).
to
eq
(
master_pickable_commit
.
cherry_pick_message
(
project
,
'master'
))
expect
(
json_response
[
'message'
]).
to
eq
(
master_pickable_commit
.
cherry_pick_message
(
user
))
expect
(
json_response
[
'author_name'
]).
to
eq
(
master_pickable_commit
.
author_name
)
expect
(
json_response
[
'committer_name'
]).
to
eq
(
user
.
name
)
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