From 394107f5f6a5bc5d5df80ce1120ff3d3b8b5693e Mon Sep 17 00:00:00 2001
From: Peter Leitzen <pl@neopoly.de>
Date: Mon, 23 Jul 2018 22:16:00 +0200
Subject: [PATCH] Link to the tag in system note

---
 app/services/system_note_service.rb       | 3 ++-
 spec/services/system_note_service_spec.rb | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 452b80b1bfa..dda89830179 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -41,7 +41,8 @@ module SystemNoteService
   #
   # Returns the created Note object
   def tag_commit(noteable, project, author, tag_name)
-    body = "tagged commit #{noteable.sha} to `#{tag_name}`"
+    link = url_helpers.project_tag_url(project, id: tag_name)
+    body = "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
 
     create_note(NoteSummary.new(noteable, project, author, body, action: 'tag'))
   end
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index cbe5668cf08..442de61f69b 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -112,7 +112,7 @@ describe SystemNoteService do
     let(:noteable) do
       project.commit
     end
-    let(:tag_name) { '1.2.3' }
+    let(:tag_name) { 'v1.2.3' }
 
     subject { described_class.tag_commit(noteable, project, author, tag_name) }
 
@@ -121,7 +121,9 @@ describe SystemNoteService do
     end
 
     it 'sets the note text' do
-      expect(subject.note).to eq "tagged commit #{noteable.sha} to `#{tag_name}`"
+      link = "http://localhost/#{project.full_path}/tags/#{tag_name}"
+
+      expect(subject.note).to eq "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
     end
   end
 
-- 
2.30.9