diff options
author | Zeger-Jan van de Weg <mail@zjvandeweg.nl> | 2015-11-11 13:07:02 +0100 |
---|---|---|
committer | Zeger-Jan van de Weg <mail@zjvandeweg.nl> | 2015-11-11 13:07:02 +0100 |
commit | 7e4a7d9ecc02db06c568a0de47e096edbdc1224b (patch) | |
tree | 701af1b1789f17950a22a19df4cf8f69d3beb173 /app/services/system_note_service.rb | |
parent | 3f08e4b186bd02b37f34ccf1bc641a95f9d865ce (diff) | |
parent | dfa09789061bbd3891c17ebbcc23f7bd6b95336c (diff) | |
download | gitlab-ce-7e4a7d9ecc02db06c568a0de47e096edbdc1224b.tar.gz |
Merge branch 'master' into copying-file-seen-as-licence
Diffstat (limited to 'app/services/system_note_service.rb')
-rw-r--r-- | app/services/system_note_service.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 8253c1f780d..708c2f00486 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -168,6 +168,31 @@ class SystemNoteService create_note(noteable: noteable, project: project, author: author, note: body) end + # Called when a branch in Noteable is added or deleted + # + # noteable - Noteable object + # project - Project owning noteable + # author - User performing the change + # branch_type - :source or :target + # branch - branch name + # presence - :add or :delete + # + # Example Note text: + # + # "Restored target branch `feature`" + # + # Returns the created Note object + def self.change_branch_presence(noteable, project, author, branch_type, branch, presence) + verb = + if presence == :add + 'restored' + else + 'deleted' + end + body = "#{verb} #{branch_type.to_s} branch `#{branch}`".capitalize + create_note(noteable: noteable, project: project, author: author, note: body) + end + # Called when a Mentionable references a Noteable # # noteable - Noteable object being referenced @@ -302,7 +327,7 @@ class SystemNoteService commit_ids = if count == 1 existing_commits.first.short_id else - if oldrev + if oldrev && !Gitlab::Git.blank_ref?(oldrev) "#{Commit.truncate_sha(oldrev)}...#{existing_commits.last.short_id}" else "#{existing_commits.first.short_id}..#{existing_commits.last.short_id}" |