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
Tatuya Kamada
gitlab-ce
Commits
27af24c1
Commit
27af24c1
authored
Apr 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No longer needed to pass project argument to commit methods.
parent
8ed7ac9d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
26 additions
and
31 deletions
+26
-31
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+3
-3
app/models/commit.rb
app/models/commit.rb
+7
-7
app/models/merge_request.rb
app/models/merge_request.rb
+2
-2
app/services/git_push_service.rb
app/services/git_push_service.rb
+1
-1
app/services/notification_service.rb
app/services/notification_service.rb
+1
-3
app/services/projects/participants_service.rb
app/services/projects/participants_service.rb
+7
-9
app/views/projects/commits/_commit.html.haml
app/views/projects/commits/_commit.html.haml
+1
-1
lib/gitlab/note_data_builder.rb
lib/gitlab/note_data_builder.rb
+1
-1
lib/gitlab/push_data_builder.rb
lib/gitlab/push_data_builder.rb
+1
-2
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+2
-2
No files found.
app/controllers/projects/commit_controller.rb
View file @
27af24c1
...
@@ -10,11 +10,11 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -10,11 +10,11 @@ class Projects::CommitController < Projects::ApplicationController
def
show
def
show
return
git_not_found!
unless
@commit
return
git_not_found!
unless
@commit
@line_notes
=
commit
.
notes
(
@project
)
.
inline
@line_notes
=
commit
.
notes
.
inline
@diffs
=
@commit
.
diffs
@diffs
=
@commit
.
diffs
@note
=
@project
.
build_commit_note
(
commit
)
@note
=
@project
.
build_commit_note
(
commit
)
@notes_count
=
commit
.
notes
(
@project
)
.
count
@notes_count
=
commit
.
notes
.
count
@notes
=
commit
.
notes
(
@project
)
.
not_inline
.
fresh
@notes
=
commit
.
notes
.
not_inline
.
fresh
@noteable
=
@commit
@noteable
=
@commit
@comments_allowed
=
@reply_allowed
=
true
@comments_allowed
=
@reply_allowed
=
true
@comments_target
=
{
@comments_target
=
{
...
...
app/models/commit.rb
View file @
27af24c1
...
@@ -103,7 +103,7 @@ class Commit
...
@@ -103,7 +103,7 @@ class Commit
description
.
present?
description
.
present?
end
end
def
hook_attrs
(
project
)
def
hook_attrs
path_with_namespace
=
project
.
path_with_namespace
path_with_namespace
=
project
.
path_with_namespace
{
{
...
@@ -120,7 +120,7 @@ class Commit
...
@@ -120,7 +120,7 @@ class Commit
# Discover issues should be closed when this commit is pushed to a project's
# Discover issues should be closed when this commit is pushed to a project's
# default branch.
# default branch.
def
closes_issues
(
project
,
current_user
=
self
.
committer
)
def
closes_issues
(
current_user
=
self
.
committer
)
Gitlab
::
ClosingIssueExtractor
.
new
(
project
,
current_user
).
closed_by_message
(
safe_message
)
Gitlab
::
ClosingIssueExtractor
.
new
(
project
,
current_user
).
closed_by_message
(
safe_message
)
end
end
...
@@ -137,22 +137,22 @@ class Commit
...
@@ -137,22 +137,22 @@ class Commit
User
.
find_for_commit
(
committer_email
,
committer_name
)
User
.
find_for_commit
(
committer_email
,
committer_name
)
end
end
def
participants
(
project
,
current_user
=
nil
)
def
participants
(
current_user
=
nil
)
users
=
[]
users
=
[]
users
<<
author
users
<<
author
users
<<
committer
users
<<
committer
users
.
push
*
self
.
mentioned_users
(
current_user
,
project
)
users
.
push
*
self
.
mentioned_users
(
current_user
)
notes
(
project
)
.
each
do
|
note
|
notes
.
each
do
|
note
|
users
<<
note
.
author
users
<<
note
.
author
users
.
push
*
note
.
mentioned_users
(
current_user
,
project
)
users
.
push
*
note
.
mentioned_users
(
current_user
)
end
end
users
.
uniq
users
.
uniq
end
end
def
notes
(
project
)
def
notes
project
.
notes
.
for_commit_id
(
self
.
id
)
project
.
notes
.
for_commit_id
(
self
.
id
)
end
end
...
...
app/models/merge_request.rb
View file @
27af24c1
...
@@ -242,7 +242,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -242,7 +242,7 @@ class MergeRequest < ActiveRecord::Base
}
}
unless
last_commit
.
nil?
unless
last_commit
.
nil?
attrs
.
merge!
(
last_commit:
last_commit
.
hook_attrs
(
source_project
)
)
attrs
.
merge!
(
last_commit:
last_commit
.
hook_attrs
)
end
end
attributes
.
merge!
(
attrs
)
attributes
.
merge!
(
attrs
)
...
@@ -259,7 +259,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -259,7 +259,7 @@ class MergeRequest < ActiveRecord::Base
# Return the set of issues that will be closed if this merge request is accepted.
# Return the set of issues that will be closed if this merge request is accepted.
def
closes_issues
(
current_user
=
self
.
author
)
def
closes_issues
(
current_user
=
self
.
author
)
if
target_branch
==
project
.
default_branch
if
target_branch
==
project
.
default_branch
issues
=
commits
.
flat_map
{
|
c
|
c
.
closes_issues
(
project
,
current_user
)
}
issues
=
commits
.
flat_map
{
|
c
|
c
.
closes_issues
(
current_user
)
}
issues
.
push
(
*
Gitlab
::
ClosingIssueExtractor
.
new
(
project
,
current_user
).
issues
.
push
(
*
Gitlab
::
ClosingIssueExtractor
.
new
(
project
,
current_user
).
closed_by_message
(
description
))
closed_by_message
(
description
))
issues
.
uniq
.
sort_by
(
&
:id
)
issues
.
uniq
.
sort_by
(
&
:id
)
...
...
app/services/git_push_service.rb
View file @
27af24c1
...
@@ -70,7 +70,7 @@ class GitPushService
...
@@ -70,7 +70,7 @@ class GitPushService
# Close issues if these commits were pushed to the project's default branch and the commit message matches the
# Close issues if these commits were pushed to the project's default branch and the commit message matches the
# closing regex. Exclude any mentioned Issues from cross-referencing even if the commits are being pushed to
# closing regex. Exclude any mentioned Issues from cross-referencing even if the commits are being pushed to
# a different branch.
# a different branch.
issues_to_close
=
commit
.
closes_issues
(
project
,
user
)
issues_to_close
=
commit
.
closes_issues
(
user
)
# Load commit author only if needed.
# Load commit author only if needed.
# For push with 1k commits it prevents 900+ requests in database
# For push with 1k commits it prevents 900+ requests in database
...
...
app/services/notification_service.rb
View file @
27af24c1
...
@@ -129,9 +129,7 @@ class NotificationService
...
@@ -129,9 +129,7 @@ class NotificationService
# Add all users participating in the thread (author, assignee, comment authors)
# Add all users participating in the thread (author, assignee, comment authors)
participants
=
participants
=
if
target
.
is_a?
(
Commit
)
if
target
.
respond_to?
(
:participants
)
target
.
participants
(
note
.
project
,
note
.
author
)
elsif
target
.
respond_to?
(
:participants
)
target
.
participants
(
note
.
author
)
target
.
participants
(
note
.
author
)
else
else
note
.
mentioned_users
note
.
mentioned_users
...
...
app/services/projects/participants_service.rb
View file @
27af24c1
...
@@ -13,21 +13,19 @@ module Projects
...
@@ -13,21 +13,19 @@ module Projects
end
end
def
participants_in
(
type
,
id
)
def
participants_in
(
type
,
id
)
users
=
target
=
case
type
case
type
when
"Issue"
when
"Issue"
issue
=
project
.
issues
.
find_by_iid
(
id
)
project
.
issues
.
find_by_iid
(
id
)
issue
.
participants
(
current_user
)
if
issue
when
"MergeRequest"
when
"MergeRequest"
merge_request
=
project
.
merge_requests
.
find_by_iid
(
id
)
project
.
merge_requests
.
find_by_iid
(
id
)
merge_request
.
participants
(
current_user
)
if
merge_request
when
"Commit"
when
"Commit"
commit
=
project
.
commit
(
id
)
project
.
commit
(
id
)
commit
.
participants
(
project
,
current_user
)
if
commit
end
end
return
[]
unless
target
return
[]
unless
users
users
=
target
.
participants
(
current_user
)
sorted
(
users
)
sorted
(
users
)
end
end
...
...
app/views/projects/commits/_commit.html.haml
View file @
27af24c1
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
-
if
@note_counts
-
if
@note_counts
-
note_count
=
@note_counts
.
fetch
(
commit
.
id
,
0
)
-
note_count
=
@note_counts
.
fetch
(
commit
.
id
,
0
)
-
else
-
else
-
notes
=
commit
.
notes
(
project
)
-
notes
=
commit
.
notes
-
note_count
=
notes
.
user
.
count
-
note_count
=
notes
.
user
.
count
-
if
note_count
>
0
-
if
note_count
>
0
...
...
lib/gitlab/note_data_builder.rb
View file @
27af24c1
...
@@ -70,7 +70,7 @@ module Gitlab
...
@@ -70,7 +70,7 @@ module Gitlab
def
build_data_for_commit
(
project
,
user
,
note
)
def
build_data_for_commit
(
project
,
user
,
note
)
# commit_id is the SHA hash
# commit_id is the SHA hash
commit
=
project
.
commit
(
note
.
commit_id
)
commit
=
project
.
commit
(
note
.
commit_id
)
commit
.
hook_attrs
(
project
)
commit
.
hook_attrs
end
end
end
end
end
end
...
...
lib/gitlab/push_data_builder.rb
View file @
27af24c1
...
@@ -30,8 +30,7 @@ module Gitlab
...
@@ -30,8 +30,7 @@ module Gitlab
# For performance purposes maximum 20 latest commits
# For performance purposes maximum 20 latest commits
# will be passed as post receive hook data.
# will be passed as post receive hook data.
commit_attrs
=
commits_limited
.
map
do
|
commit
|
commit_attrs
=
commits_limited
.
map
(
&
:hook_attrs
)
commit
.
hook_attrs
(
project
)
end
end
type
=
Gitlab
::
Git
.
tag_ref?
(
ref
)
?
"tag_push"
:
"push"
type
=
Gitlab
::
Git
.
tag_ref?
(
ref
)
?
"tag_push"
:
"push"
...
...
spec/models/commit_spec.rb
View file @
27af24c1
...
@@ -58,13 +58,13 @@ eos
...
@@ -58,13 +58,13 @@ eos
it
'detects issues that this commit is marked as closing'
do
it
'detects issues that this commit is marked as closing'
do
commit
.
stub
(
safe_message:
"Fixes #
#{
issue
.
iid
}
"
)
commit
.
stub
(
safe_message:
"Fixes #
#{
issue
.
iid
}
"
)
expect
(
commit
.
closes_issues
(
project
)
).
to
eq
([
issue
])
expect
(
commit
.
closes_issues
).
to
eq
([
issue
])
end
end
it
'does not detect issues from other projects'
do
it
'does not detect issues from other projects'
do
ext_ref
=
"
#{
other_project
.
path_with_namespace
}
#
#{
other_issue
.
iid
}
"
ext_ref
=
"
#{
other_project
.
path_with_namespace
}
#
#{
other_issue
.
iid
}
"
commit
.
stub
(
safe_message:
"Fixes
#{
ext_ref
}
"
)
commit
.
stub
(
safe_message:
"Fixes
#{
ext_ref
}
"
)
expect
(
commit
.
closes_issues
(
project
)
).
to
be_empty
expect
(
commit
.
closes_issues
).
to
be_empty
end
end
end
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