Commit a1abe761 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'jira-related-improvements' into 'master'

Small refactors (JIRA related code)

See merge request gitlab-org/gitlab!17629
parents 60a75b12 dd96d97f
...@@ -137,10 +137,9 @@ class JiraService < IssueTrackerService ...@@ -137,10 +137,9 @@ class JiraService < IssueTrackerService
return if issue.nil? || has_resolution?(issue) || !jira_issue_transition_id.present? return if issue.nil? || has_resolution?(issue) || !jira_issue_transition_id.present?
commit_id = if entity.is_a?(Commit) commit_id = case entity
entity.id when Commit then entity.id
elsif entity.is_a?(MergeRequest) when MergeRequest then entity.diff_head_sha
entity.diff_head_sha
end end
commit_url = build_entity_url(:commit, commit_id) commit_url = build_entity_url(:commit, commit_id)
...@@ -331,7 +330,6 @@ class JiraService < IssueTrackerService ...@@ -331,7 +330,6 @@ class JiraService < IssueTrackerService
# Handle errors when doing Jira API calls # Handle errors when doing Jira API calls
def jira_request def jira_request
yield yield
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, URI::InvalidURIError, JIRA::HTTPError, OpenSSL::SSL::SSLError => e rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, URI::InvalidURIError, JIRA::HTTPError, OpenSSL::SSL::SSLError => e
@error = e.message @error = e.message
log_error("Error sending message", client_url: client_url, error: @error) log_error("Error sending message", client_url: client_url, error: @error)
......
...@@ -18,7 +18,7 @@ module Issues ...@@ -18,7 +18,7 @@ module Issues
# The code calling this method is responsible for ensuring that a user is # The code calling this method is responsible for ensuring that a user is
# allowed to close the given issue. # allowed to close the given issue.
def close_issue(issue, closed_via: nil, notifications: true, system_note: true) def close_issue(issue, closed_via: nil, notifications: true, system_note: true)
if project.jira_tracker? && project.jira_service.active && issue.is_a?(ExternalIssue) if project.jira_tracker_active? && issue.is_a?(ExternalIssue)
project.jira_service.close_issue(closed_via, issue) project.jira_service.close_issue(closed_via, issue)
todo_service.close_issue(issue, current_user) todo_service.close_issue(issue, current_user)
return issue return issue
......
...@@ -4,7 +4,7 @@ module Gitlab ...@@ -4,7 +4,7 @@ module Gitlab
module Jira module Jira
# Gitlab JIRA HTTP client to be used with jira-ruby gem, this subclasses JIRA::HTTPClient. # Gitlab JIRA HTTP client to be used with jira-ruby gem, this subclasses JIRA::HTTPClient.
# Uses Gitlab::HTTP to make requests to JIRA REST API. # Uses Gitlab::HTTP to make requests to JIRA REST API.
# The parent class implementation can be found at: https://github.com/sumoheavy/jira-ruby/blob/v1.4.0/lib/jira/http_client.rb # The parent class implementation can be found at: https://github.com/sumoheavy/jira-ruby/blob/v1.7.0/lib/jira/http_client.rb
class HttpClient < JIRA::HttpClient class HttpClient < JIRA::HttpClient
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
...@@ -24,7 +24,7 @@ module Gitlab ...@@ -24,7 +24,7 @@ module Gitlab
password: @options.delete(:password) password: @options.delete(:password)
}.to_json }.to_json
make_request(:post, @options[:context_path] + '/rest/auth/1/session', body, { 'Content-Type' => 'application/json' }) make_request(:post, @options[:context_path] + '/rest/auth/1/session', body, 'Content-Type' => 'application/json')
end end
override :make_request override :make_request
......
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