Merge branch 'relative-urls-for-system-notes' into 'master'
Change system notes to use relative urls Closes #55441 See merge request gitlab-org/gitlab-ce!28588
This commit is contained in:
commit
b68aa027d4
3 changed files with 13 additions and 8 deletions
|
@ -25,7 +25,7 @@ module SystemNoteService
|
||||||
|
|
||||||
text_parts = ["added #{commits_text}"]
|
text_parts = ["added #{commits_text}"]
|
||||||
text_parts << commits_list(noteable, new_commits, existing_commits, oldrev)
|
text_parts << commits_list(noteable, new_commits, existing_commits, oldrev)
|
||||||
text_parts << "[Compare with previous version](#{diff_comparison_url(noteable, project, oldrev)})"
|
text_parts << "[Compare with previous version](#{diff_comparison_path(noteable, project, oldrev)})"
|
||||||
|
|
||||||
body = text_parts.join("\n\n")
|
body = text_parts.join("\n\n")
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ module SystemNoteService
|
||||||
#
|
#
|
||||||
# Returns the created Note object
|
# Returns the created Note object
|
||||||
def tag_commit(noteable, project, author, tag_name)
|
def tag_commit(noteable, project, author, tag_name)
|
||||||
link = url_helpers.project_tag_url(project, id: tag_name)
|
link = url_helpers.project_tag_path(project, id: tag_name)
|
||||||
body = "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
|
body = "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
|
||||||
|
|
||||||
create_note(NoteSummary.new(noteable, project, author, body, action: 'tag'))
|
create_note(NoteSummary.new(noteable, project, author, body, action: 'tag'))
|
||||||
|
@ -272,7 +272,7 @@ module SystemNoteService
|
||||||
text_parts = ["changed this line in"]
|
text_parts = ["changed this line in"]
|
||||||
if version_params = merge_request.version_params_for(diff_refs)
|
if version_params = merge_request.version_params_for(diff_refs)
|
||||||
line_code = change_position.line_code(project.repository)
|
line_code = change_position.line_code(project.repository)
|
||||||
url = url_helpers.diffs_project_merge_request_url(project, merge_request, version_params.merge(anchor: line_code))
|
url = url_helpers.diffs_project_merge_request_path(project, merge_request, version_params.merge(anchor: line_code))
|
||||||
|
|
||||||
text_parts << "[version #{version_index} of the diff](#{url})"
|
text_parts << "[version #{version_index} of the diff](#{url})"
|
||||||
else
|
else
|
||||||
|
@ -405,7 +405,7 @@ module SystemNoteService
|
||||||
#
|
#
|
||||||
# "created branch `201-issue-branch-button`"
|
# "created branch `201-issue-branch-button`"
|
||||||
def new_issue_branch(issue, project, author, branch)
|
def new_issue_branch(issue, project, author, branch)
|
||||||
link = url_helpers.project_compare_url(project, from: project.default_branch, to: branch)
|
link = url_helpers.project_compare_path(project, from: project.default_branch, to: branch)
|
||||||
|
|
||||||
body = "created branch [`#{branch}`](#{link}) to address this issue"
|
body = "created branch [`#{branch}`](#{link}) to address this issue"
|
||||||
|
|
||||||
|
@ -668,10 +668,10 @@ module SystemNoteService
|
||||||
@url_helpers ||= Gitlab::Routing.url_helpers
|
@url_helpers ||= Gitlab::Routing.url_helpers
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff_comparison_url(merge_request, project, oldrev)
|
def diff_comparison_path(merge_request, project, oldrev)
|
||||||
diff_id = merge_request.merge_request_diff.id
|
diff_id = merge_request.merge_request_diff.id
|
||||||
|
|
||||||
url_helpers.diffs_project_merge_request_url(
|
url_helpers.diffs_project_merge_request_path(
|
||||||
project,
|
project,
|
||||||
merge_request,
|
merge_request,
|
||||||
diff_id: diff_id,
|
diff_id: diff_id,
|
||||||
|
|
5
changelogs/unreleased/relative-urls-for-system-notes.yml
Normal file
5
changelogs/unreleased/relative-urls-for-system-notes.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Change links in system notes to use relative paths
|
||||||
|
merge_request: 28588
|
||||||
|
author: Luke Picciau
|
||||||
|
type: fixed
|
|
@ -132,7 +132,7 @@ describe SystemNoteService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets the note text' do
|
it 'sets the note text' do
|
||||||
link = "http://localhost/#{project.full_path}/-/tags/#{tag_name}"
|
link = "/#{project.full_path}/-/tags/#{tag_name}"
|
||||||
|
|
||||||
expect(subject.note).to eq "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
|
expect(subject.note).to eq "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
|
||||||
end
|
end
|
||||||
|
@ -1139,7 +1139,7 @@ describe SystemNoteService do
|
||||||
|
|
||||||
diff_id = merge_request.merge_request_diff.id
|
diff_id = merge_request.merge_request_diff.id
|
||||||
line_code = change_position.line_code(project.repository)
|
line_code = change_position.line_code(project.repository)
|
||||||
expect(subject.note).to include(diffs_project_merge_request_url(project, merge_request, diff_id: diff_id, anchor: line_code))
|
expect(subject.note).to include(diffs_project_merge_request_path(project, merge_request, diff_id: diff_id, anchor: line_code))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue