diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-24 21:07:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-24 21:07:52 +0300 |
commit | 80c12cd5b2d42f4be0b1a9b550f0441157de7144 (patch) | |
tree | e84398f1721ff4e1a2855b346182a8b869ed1a44 /app | |
parent | 7173270eb496d0bec6759a22c4af7a4f37ca8dd7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/presenters/gitlab/blame_presenter.rb | 16 | ||||
-rw-r--r-- | app/services/issuable_links/create_service.rb | 12 |
2 files changed, 19 insertions, 9 deletions
diff --git a/app/presenters/gitlab/blame_presenter.rb b/app/presenters/gitlab/blame_presenter.rb index 5dd2f3adda5..2244bcc1545 100644 --- a/app/presenters/gitlab/blame_presenter.rb +++ b/app/presenters/gitlab/blame_presenter.rb @@ -32,8 +32,8 @@ module Gitlab @groups ||= blame.groups end - def commit_data(commit) - @commits[commit.id] ||= get_commit_data(commit) + def commit_data(commit, previous_path = nil) + @commits[commit.id] ||= get_commit_data(commit, previous_path) end private @@ -44,25 +44,25 @@ module Gitlab # to avoid recalculating it multiple times. # For such files, it could significantly improve the performance of the Blame. def precalculate_data_by_commit! - groups.each { |group| commit_data(group[:commit]) } + groups.each { |group| commit_data(group[:commit], group[:previous_path]) } end - def get_commit_data(commit) + def get_commit_data(commit, previous_path = nil) CommitData.new.tap do |data| data.author_avatar = author_avatar(commit, size: 36, has_tooltip: false, lazy: true) data.age_map_class = age_map_class(commit.committed_date, project_duration) data.commit_link = link_to commit.title, project_commit_path(project, commit.id), class: "cdark", title: commit.title data.commit_author_link = commit_author_link(commit, avatar: false) - data.project_blame_link = project_blame_link(commit) + data.project_blame_link = project_blame_link(commit, previous_path) data.time_ago_tooltip = time_ago_with_tooltip(commit.committed_date) end end - def project_blame_link(commit) + def project_blame_link(commit, previous_path = nil) previous_commit_id = commit.parent_id - return unless previous_commit_id + return unless previous_commit_id && !previous_path.nil? - link_to project_blame_path(project, tree_join(previous_commit_id, path)), + link_to project_blame_path(project, tree_join(previous_commit_id, previous_path)), title: _('View blame prior to this change'), aria: { label: _('View blame prior to this change') }, class: 'version-link', diff --git a/app/services/issuable_links/create_service.rb b/app/services/issuable_links/create_service.rb index 44f26ba52dc..0887f04760c 100644 --- a/app/services/issuable_links/create_service.rb +++ b/app/services/issuable_links/create_service.rb @@ -67,7 +67,9 @@ module IssuableLinks target_issuables.map do |referenced_object| link = relate_issuables(referenced_object) - unless link.valid? + if link.valid? + after_create_for(link) + else @errors << _("%{ref} cannot be added: %{error}") % { ref: referenced_object.to_reference, error: link.errors.messages.values.flatten.to_sentence @@ -143,9 +145,17 @@ module IssuableLinks # no-op end + # Override on child classes to perform + # actions when the service is executed. def track_event # no-op end + + # Override on child classes to + # perform actions for each object created. + def after_create_for(_link) + # no-op + end end end |