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
096850a4
Commit
096850a4
authored
Sep 01, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sm-cherry-pick-list-commits-in-message' into 'master'
Add 'from commit' information to cherry-picked commits See merge request !13475
parents
15ad0ac1
934eef72
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
4 deletions
+95
-4
commit.rb
app/models/commit.rb
+22
-0
repository.rb
app/models/repository.rb
+1
-1
sm-cherry-pick-list-commits-in-message.yml
...ogs/unreleased/sm-cherry-pick-list-commits-in-message.yml
+5
-0
commit_spec.rb
spec/models/commit_spec.rb
+61
-0
repository_spec.rb
spec/models/repository_spec.rb
+4
-1
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 @
096850a4
...
...
@@ -251,6 +251,28 @@ class Commit
project
.
repository
.
next_branch
(
"cherry-pick-
#{
short_id
}
"
,
mild:
true
)
end
def
cherry_pick_description
(
user
)
message_body
=
"(cherry picked from commit
#{
sha
}
)"
if
merged_merge_request?
(
user
)
commits_in_merge_request
=
merged_merge_request
(
user
).
commits
if
commits_in_merge_request
.
present?
message_body
<<
"
\n
"
commits_in_merge_request
.
reverse
.
each
do
|
commit_in_merge
|
message_body
<<
"
\n
#{
commit_in_merge
.
short_id
}
#{
commit_in_merge
.
title
}
"
end
end
end
message_body
end
def
cherry_pick_message
(
user
)
%Q{
#{
message
}
\n\n
#{
cherry_pick_description
(
user
)
}
}
end
def
revert_description
(
user
)
if
merged_merge_request?
(
user
)
"This reverts merge request
#{
merged_merge_request
(
user
).
to_reference
}
"
...
...
app/models/repository.rb
View file @
096850a4
...
...
@@ -908,7 +908,7 @@ class Repository
committer
=
user_to_committer
(
user
)
create_commit
(
message:
commit
.
message
,
create_commit
(
message:
commit
.
cherry_pick_message
(
user
)
,
author:
{
email:
commit
.
author_email
,
name:
commit
.
author_name
,
...
...
changelogs/unreleased/sm-cherry-pick-list-commits-in-message.yml
0 → 100644
View file @
096850a4
---
title
:
Add 'from commit' information to cherry-picked commits
merge_request
:
13475
author
:
Saverio Miroddi
type
:
added
spec/models/commit_spec.rb
View file @
096850a4
...
...
@@ -195,6 +195,67 @@ eos
it
{
expect
(
data
[
:removed
]).
to
eq
([])
}
end
describe
'#cherry_pick_message'
do
let
(
:user
)
{
create
(
:user
)
}
context
'of a regular commit'
do
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
)
{
message:
'Test message'
,
committer:
author
,
author:
author
}
end
let
(
:merge_request
)
do
create
(
:merge_request
,
source_branch:
'video'
,
target_branch:
'master'
,
source_project:
project
,
author:
user
)
end
let
(
:merge_commit
)
do
merge_commit_id
=
repository
.
merge
(
user
,
merge_request
.
diff_head_sha
,
merge_request
,
commit_options
)
repository
.
commit
(
merge_commit_id
)
end
context
'that is found'
do
before
do
# Artificially mark as completed.
merge_request
.
update
(
merge_commit_sha:
merge_commit
.
id
)
end
it
do
expected_appended_text
=
<<~
STR
.
rstrip
(cherry picked from commit
#{
merge_commit
.
sha
}
)
467dc98f Add new 'videos' directory
88790590 Upload new video file
STR
expect
(
merge_commit
.
cherry_pick_message
(
user
)).
to
include
(
expected_appended_text
)
end
end
context
"that is existing but not found"
do
it
'does not include details of the merged commits'
do
expect
(
merge_commit
.
cherry_pick_message
(
user
)).
to
end_with
(
"(cherry picked from commit
#{
merge_commit
.
sha
}
)"
)
end
end
end
end
describe
'#reverts_commit?'
do
let
(
:another_commit
)
{
double
(
:commit
,
revert_description:
"This reverts commit
#{
commit
.
sha
}
"
)
}
let
(
:user
)
{
commit
.
author
}
...
...
spec/models/repository_spec.rb
View file @
096850a4
...
...
@@ -1379,8 +1379,11 @@ describe Repository, models: true do
it
'cherry-picks the changes'
do
expect
(
repository
.
blob_at_branch
(
'improve/awesome'
,
'foo/bar/.gitkeep'
)).
to
be_nil
repository
.
cherry_pick
(
user
,
pickable_merge
,
'improve/awesome'
)
cherry_pick_commit_sha
=
repository
.
cherry_pick
(
user
,
pickable_merge
,
'improve/awesome'
)
cherry_pick_commit_message
=
project
.
commit
(
cherry_pick_commit_sha
).
message
expect
(
repository
.
blob_at_branch
(
'improve/awesome'
,
'foo/bar/.gitkeep'
)).
not_to
be_nil
expect
(
cherry_pick_commit_message
).
to
include
(
'cherry picked from'
)
end
end
end
...
...
spec/requests/api/commits_spec.rb
View file @
096850a4
...
...
@@ -804,7 +804,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
.
message
)
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 @
096850a4
...
...
@@ -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
.
message
)
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