Class: SystemNotes::CommitService
- Inherits:
-
BaseService
- Object
- BaseService
- SystemNotes::CommitService
- Defined in:
- app/services/system_notes/commit_service.rb
Constant Summary collapse
- NEW_COMMIT_DISPLAY_LIMIT =
10
Instance Attribute Summary
Attributes inherited from BaseService
#author, #container, #group, #noteable, #project
Instance Method Summary collapse
-
#add_commits(new_commits, existing_commits = [], oldrev = nil) ⇒ Object
Called when commits are added to a merge request.
-
#tag_commit(tag_name) ⇒ Object
Called when a commit was tagged.
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from SystemNotes::BaseService
Instance Method Details
#add_commits(new_commits, existing_commits = [], oldrev = nil) ⇒ Object
Called when commits are added to a merge request
new_commits - Array of Commits added since last push existing_commits - Array of Commits added in a previous push oldrev - Optional String SHA of a previous Commit
See new_commit_summary and existing_commit_summary.
Returns the created Note object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/system_notes/commit_service.rb', line 16 def add_commits(new_commits, existing_commits = [], oldrev = nil) total_count = new_commits.length + existing_commits.length commits_text = "#{total_count} commit".pluralize(total_count) text_parts = ["added #{commits_text}"] text_parts << commits_list(noteable, new_commits, existing_commits, oldrev) text_parts << "[Compare with previous version](#{diff_comparison_path(noteable, project, oldrev)})" body = text_parts.join("\n\n") create_note(NoteSummary.new(noteable, project, , body, action: 'commit', commit_count: total_count)) end |
#tag_commit(tag_name) ⇒ Object
Called when a commit was tagged
tag_name - The created tag name
Returns the created Note object
34 35 36 37 38 39 |
# File 'app/services/system_notes/commit_service.rb', line 34 def tag_commit(tag_name) link = url_helpers.project_tag_path(project, id: tag_name) body = "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})" create_note(NoteSummary.new(noteable, project, , body, action: 'tag')) end |