diff options
author | Peter Leitzen <pl@neopoly.de> | 2018-07-21 15:57:52 +0300 |
---|---|---|
committer | Peter Leitzen <pl@neopoly.de> | 2018-08-10 17:45:11 +0300 |
commit | 7a4b288ec96e64bd9eaf1296d319a39401901df4 (patch) | |
tree | e8b488873903d3ec07a5dd0df0cdf006efcde088 /app | |
parent | d6eaf38be4fa1785b6e47eeb76f4ca2cb20a144d (diff) |
Create a system note after tagging a commit
Diffstat (limited to 'app')
-rw-r--r-- | app/models/system_note_metadata.rb | 2 | ||||
-rw-r--r-- | app/services/commits/update_service.rb | 3 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 14 |
3 files changed, 17 insertions, 2 deletions
diff --git a/app/models/system_note_metadata.rb b/app/models/system_note_metadata.rb index c5c77bc8333..376ef673ca8 100644 --- a/app/models/system_note_metadata.rb +++ b/app/models/system_note_metadata.rb @@ -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 diff --git a/app/services/commits/update_service.rb b/app/services/commits/update_service.rb index 7ec678ff1cf..45c971d153a 100644 --- a/app/services/commits/update_service.rb +++ b/app/services/commits/update_service.rb @@ -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 diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 77494295f14..452b80b1bfa 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -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 |