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
e77ba96f
Commit
e77ba96f
authored
Sep 05, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mr-push-note' into 'master'
Add comment to merge request when new push happens Fixes #1494 See merge request !1065
parents
e088777e
fd6b7b4a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
3 deletions
+39
-3
note.rb
app/models/note.rb
+19
-0
project.rb
app/models/project.rb
+20
-3
No files found.
app/models/note.rb
View file @
e77ba96f
...
...
@@ -117,6 +117,25 @@ class Note < ActiveRecord::Base
})
end
def
create_new_commits_note
(
noteable
,
project
,
author
,
commits
)
commits_text
=
ActionController
::
Base
.
helpers
.
pluralize
(
commits
.
size
,
'new commit'
)
body
=
"Added
#{
commits_text
}
:
\n\n
"
commits
.
each
do
|
commit
|
message
=
"*
#{
commit
.
short_id
}
-
#{
commit
.
title
}
"
body
<<
message
body
<<
"
\n
"
end
create
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
,
system:
true
)
end
def
discussions_from_notes
(
notes
)
discussion_ids
=
[]
discussions
=
[]
...
...
app/models/project.rb
View file @
e77ba96f
...
...
@@ -400,18 +400,35 @@ class Project < ActiveRecord::Base
def
update_merge_requests
(
oldrev
,
newrev
,
ref
,
user
)
return
true
unless
ref
=~
/heads/
branch_name
=
ref
.
gsub
(
"refs/heads/"
,
""
)
c_ids
=
self
.
repository
.
commits_between
(
oldrev
,
newrev
).
map
(
&
:id
)
commits
=
self
.
repository
.
commits_between
(
oldrev
,
newrev
)
c_ids
=
commits
.
map
(
&
:id
)
# Close merge requests
mrs
=
self
.
merge_requests
.
opened
.
where
(
target_branch:
branch_name
).
to_a
mrs
=
mrs
.
select
(
&
:last_commit
).
select
{
|
mr
|
c_ids
.
include?
(
mr
.
last_commit
.
id
)
}
mrs
.
each
{
|
merge_request
|
MergeRequests
::
MergeService
.
new
.
execute
(
merge_request
,
user
,
nil
)
}
mrs
.
uniq
.
each
do
|
merge_request
|
MergeRequests
::
MergeService
.
new
.
execute
(
merge_request
,
user
,
nil
)
end
# Update code for merge requests into project between project branches
mrs
=
self
.
merge_requests
.
opened
.
by_branch
(
branch_name
).
to_a
# Update code for merge requests between project and project fork
mrs
+=
self
.
fork_merge_requests
.
opened
.
by_branch
(
branch_name
).
to_a
mrs
.
each
{
|
merge_request
|
merge_request
.
reload_code
;
merge_request
.
mark_as_unchecked
}
mrs
.
uniq
.
each
do
|
merge_request
|
merge_request
.
reload_code
merge_request
.
mark_as_unchecked
end
# Add comment about pushing new commits to merge requests
mrs
=
self
.
merge_requests
.
opened
.
where
(
source_branch:
branch_name
).
to_a
mrs
+=
self
.
fork_merge_requests
.
opened
.
where
(
source_branch:
branch_name
).
to_a
mrs
.
uniq
.
each
do
|
merge_request
|
Note
.
create_new_commits_note
(
merge_request
,
merge_request
.
project
,
user
,
commits
)
end
true
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