Commit 3e697062 authored by Marin Jankovski's avatar Marin Jankovski

Nicer closing message in comment.

parent 1173f2e7
...@@ -95,18 +95,18 @@ class JiraService < IssueTrackerService ...@@ -95,18 +95,18 @@ class JiraService < IssueTrackerService
def close_issue(push_data, issue_name) def close_issue(push_data, issue_name)
url = close_issue_url(issue_name) url = close_issue_url(issue_name)
commit_url = push_data[:commits].first[:url] commit = push_data[:commits].first
message = { message = {
'update' => { update: {
'comment' => [{ comment: [{
'add' => { add: {
'body' => "Issue solved with #{commit_url}" body: "Issue solved with [#{commit[:id]}|#{commit[:url]}]."
} }
}] }]
}, },
'transition' => { transition: {
'id' => jira_issue_transition_id id: jira_issue_transition_id
} }
}.to_json }.to_json
...@@ -130,13 +130,6 @@ class JiraService < IssueTrackerService ...@@ -130,13 +130,6 @@ class JiraService < IssueTrackerService
send_message(url, message) send_message(url, message)
end end
def close_issue_url(issue_name)
"#{server_url}/rest/api/#{self.api_version}/issue/#{issue_name}/transitions"
end
def add_comment_url(issue_name)
"#{server_url}/rest/api/#{self.api_version}/issue/#{issue_name}/comment"
end
def auth def auth
require 'base64' require 'base64'
...@@ -185,4 +178,13 @@ class JiraService < IssueTrackerService ...@@ -185,4 +178,13 @@ class JiraService < IssueTrackerService
def resource_url(resource) def resource_url(resource)
"#{Settings.gitlab['url'].chomp("/")}#{resource}" "#{Settings.gitlab['url'].chomp("/")}#{resource}"
end end
def close_issue_url(issue_name)
"#{server_url}/rest/api/#{self.api_version}/issue/#{issue_name}/transitions"
end
def add_comment_url(issue_name)
"#{server_url}/rest/api/#{self.api_version}/issue/#{issue_name}/comment"
end
end end
...@@ -273,7 +273,7 @@ describe GitPushService do ...@@ -273,7 +273,7 @@ describe GitPushService do
update: { update: {
comment: [{ comment: [{
add: { add: {
body: "Issue solved with http://localhost/#{project.path_with_namespace}/commit/#{closing_commit.id}" body: "Issue solved with [#{closing_commit.id}|http://localhost/#{project.path_with_namespace}/commit/#{closing_commit.id}]."
} }
}] }]
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment