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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
663b3c96
Commit
663b3c96
authored
Mar 06, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Condense commits already in target branch when updating merge request source branch.
parent
8b53d9ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
6 deletions
+36
-6
CHANGELOG
CHANGELOG
+1
-0
app/models/note.rb
app/models/note.rb
+27
-4
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+7
-1
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+1
-1
No files found.
CHANGELOG
View file @
663b3c96
...
...
@@ -26,6 +26,7 @@ v 7.9.0 (unreleased)
- Add Bitbucket omniauth provider.
- Add Bitbucket importer.
- Support referencing issues to a project whose name starts with a digit
- Condense commits already in target branch when updating merge request source branch.
v 7.8.2
- Fix service migration issue when upgrading from versions prior to 7.3
...
...
app/models/note.rb
View file @
663b3c96
...
...
@@ -151,18 +151,41 @@ class Note < ActiveRecord::Base
)
end
def
create_new_commits_note
(
noteable
,
project
,
author
,
commits
)
commits_text
=
ActionController
::
Base
.
helpers
.
pluralize
(
commits
.
size
,
'new commit'
)
def
create_new_commits_note
(
merge_request
,
project
,
author
,
new_commits
,
existing_commits
=
[])
total_count
=
new_commits
.
length
+
existing_commits
.
length
commits_text
=
ActionController
::
Base
.
helpers
.
pluralize
(
total_count
,
'commit'
)
body
=
"Added
#{
commits_text
}
:
\n\n
"
commits
.
each
do
|
commit
|
if
existing_commits
.
length
>
0
commit_ids
=
if
existing_commits
.
length
==
1
existing_commits
.
first
.
short_id
else
"
#{
existing_commits
.
first
.
short_id
}
...
#{
existing_commits
.
last
.
short_id
}
"
end
commits_text
=
ActionController
::
Base
.
helpers
.
pluralize
(
existing_commits
.
length
,
'commit'
)
branch
=
if
merge_request
.
for_fork?
"
#{
merge_request
.
target_project_namespace
}
:
#{
merge_request
.
target_branch
}
"
else
merge_request
.
target_branch
end
message
=
"*
#{
commit_ids
}
- _
#{
commits_text
}
from branch `
#{
branch
}
`_"
body
<<
message
body
<<
"
\n
"
end
new_commits
.
each
do
|
commit
|
message
=
"*
#{
commit
.
short_id
}
-
#{
commit
.
title
}
"
body
<<
message
body
<<
"
\n
"
end
create
(
noteable:
noteable
,
noteable:
merge_request
,
project:
project
,
author:
author
,
note:
body
,
...
...
app/services/merge_requests/refresh_service.rb
View file @
663b3c96
...
...
@@ -82,8 +82,14 @@ module MergeRequests
merge_requests
=
filter_merge_requests
(
merge_requests
)
merge_requests
.
each
do
|
merge_request
|
mr_commit_ids
=
Set
.
new
(
merge_request
.
commits
.
map
(
&
:id
))
new_commits
,
existing_commits
=
@commits
.
partition
do
|
commit
|
mr_commit_ids
.
include?
(
commit
.
id
)
end
Note
.
create_new_commits_note
(
merge_request
,
merge_request
.
project
,
@current_user
,
@
commits
)
@current_user
,
new_commits
,
existing_
commits
)
end
end
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
663b3c96
...
...
@@ -61,7 +61,7 @@ describe MergeRequests::RefreshService do
it
{
expect
(
@merge_request
.
notes
).
to
be_empty
}
it
{
expect
(
@merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'
new commit
'
)
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'
Added 4 commits
'
)
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
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