diff options
Diffstat (limited to 'app/services/system_notes/merge_requests_service.rb')
-rw-r--r-- | app/services/system_notes/merge_requests_service.rb | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/app/services/system_notes/merge_requests_service.rb b/app/services/system_notes/merge_requests_service.rb index a51e2053394..99e03e67bf1 100644 --- a/app/services/system_notes/merge_requests_service.rb +++ b/app/services/system_notes/merge_requests_service.rb @@ -83,16 +83,26 @@ module SystemNotes # Called when a branch in Noteable is changed # # branch_type - 'source' or 'target' + # event_type - the source of event: 'update' or 'delete' # old_branch - old branch name # new_branch - new branch name + + # Example Note text is based on event_type: # - # Example Note text: - # - # "changed target branch from `Old` to `New`" + # update: "changed target branch from `Old` to `New`" + # delete: "changed automatically target branch to `New` because `Old` was deleted" # # Returns the created Note object - def change_branch(branch_type, old_branch, new_branch) - body = "changed #{branch_type} branch from `#{old_branch}` to `#{new_branch}`" + def change_branch(branch_type, event_type, old_branch, new_branch) + body = + case event_type.to_s + when 'delete' + "changed automatically #{branch_type} branch to `#{new_branch}` because `#{old_branch}` was deleted" + when 'update' + "changed #{branch_type} branch from `#{old_branch}` to `#{new_branch}`" + else + raise ArgumentError, "invalid value for event_type: #{event_type}" + end create_note(NoteSummary.new(noteable, project, author, body, action: 'branch')) end |