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
Léo-Paul Géneau
gitlab-ce
Commits
7a4b288e
Commit
7a4b288e
authored
Jul 21, 2018
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a system note after tagging a commit
parent
d6eaf38b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
3 deletions
+51
-3
app/models/system_note_metadata.rb
app/models/system_note_metadata.rb
+1
-1
app/services/commits/update_service.rb
app/services/commits/update_service.rb
+2
-1
app/services/system_note_service.rb
app/services/system_note_service.rb
+14
-0
spec/services/commits/update_service_spec.rb
spec/services/commits/update_service_spec.rb
+17
-1
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+17
-0
No files found.
app/models/system_note_metadata.rb
View file @
7a4b288e
...
...
@@ -15,7 +15,7 @@ class SystemNoteMetadata < ActiveRecord::Base
commit description merge confidential visible label assignee cross_reference
title time_tracking branch milestone discussion task moved
opened closed merged duplicate locked unlocked
outdated
outdated
tag
]
.
freeze
validates
:note
,
presence:
true
...
...
app/services/commits/update_service.rb
View file @
7a4b288e
...
...
@@ -20,7 +20,8 @@ module Commits
.
new
(
commit
.
project
,
current_user
)
.
execute
(
tag_name
,
commit
.
sha
,
message
,
release_description
)
if
result
[
:status
]
if
result
[
:status
]
==
:success
&&
(
tag
=
result
[
:tag
])
SystemNoteService
.
tag_commit
(
commit
,
commit
.
project
,
current_user
,
tag
.
name
)
commit
end
end
...
...
app/services/system_note_service.rb
View file @
7a4b288e
...
...
@@ -32,6 +32,20 @@ module SystemNoteService
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'commit'
,
commit_count:
total_count
))
end
# Called when a commit was tagged
#
# noteable - Noteable object
# project - Project owning noteable
# author - User performing the tag
# tag_name - The created tag name
#
# Returns the created Note object
def
tag_commit
(
noteable
,
project
,
author
,
tag_name
)
body
=
"tagged commit
#{
noteable
.
sha
}
to `
#{
tag_name
}
`"
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'tag'
))
end
# Called when the assignee of a Noteable is changed or removed
#
# noteable - Noteable object
...
...
spec/services/commits/update_service_spec.rb
View file @
7a4b288e
...
...
@@ -22,11 +22,26 @@ describe Commits::UpdateService do
end
it
'tags a commit'
do
tag_double
=
double
(
name:
opts
[
:tag_name
])
tag_stub
=
instance_double
(
Tags
::
CreateService
)
allow
(
Tags
::
CreateService
).
to
receive
(
:new
).
and_return
(
tag_stub
)
allow
(
tag_stub
).
to
receive
(
:execute
)
.
with
(
opts
[
:tag_name
],
commit
.
sha
,
opts
[
:tag_message
],
nil
)
.
and_return
({
status: :success
})
.
and_return
({
status: :success
,
tag:
tag_double
})
expect
(
SystemNoteService
).
to
receive
(
:tag_commit
).
with
(
commit
,
project
,
user
,
opts
[
:tag_name
])
service
.
execute
(
commit
)
end
it
'fails to tag the commit'
do
tag_stub
=
instance_double
(
Tags
::
CreateService
)
allow
(
Tags
::
CreateService
).
to
receive
(
:new
).
and_return
(
tag_stub
)
allow
(
tag_stub
).
to
receive
(
:execute
)
.
with
(
opts
[
:tag_name
],
commit
.
sha
,
opts
[
:tag_message
],
nil
)
.
and_return
({
status: :error
})
expect
(
SystemNoteService
).
not_to
receive
(
:tag_commit
)
service
.
execute
(
commit
)
end
...
...
@@ -39,6 +54,7 @@ describe Commits::UpdateService do
it
'does not call the tag create service'
do
expect
(
Tags
::
CreateService
).
not_to
receive
(
:new
)
expect
(
SystemNoteService
).
not_to
receive
(
:tag_commit
)
service
.
execute
(
commit
)
end
...
...
spec/services/system_note_service_spec.rb
View file @
7a4b288e
...
...
@@ -108,6 +108,23 @@ describe SystemNoteService do
end
end
describe
'.tag_commit'
do
let
(
:noteable
)
do
project
.
commit
end
let
(
:tag_name
)
{
'1.2.3'
}
subject
{
described_class
.
tag_commit
(
noteable
,
project
,
author
,
tag_name
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'tag'
}
end
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"tagged commit
#{
noteable
.
sha
}
to `
#{
tag_name
}
`"
end
end
describe
'.change_assignee'
do
subject
{
described_class
.
change_assignee
(
noteable
,
project
,
author
,
assignee
)
}
...
...
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