Skip to content

Commit

Permalink
Do not fail on blank Jira issue description
Browse files Browse the repository at this point in the history
  • Loading branch information
zdraganov committed May 13, 2016
1 parent 9cbb5c7 commit 5745fc3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions bin/git-jira-pr
Expand Up @@ -122,12 +122,8 @@ class App < Git::Whistles::App

title = "#{issue_id}: #{issue.summary}"
headline = "Jira story [##{issue_id}](#{@client.options[:site]}/browse/#{issue_id}) in project *#{issue.project.name}*:"
description = issue.description.split("\n").map do |line|
(1..6).each { |i| line.gsub!(/(h#{i}.)/, '#' * i) }
line.gsub!(/({{)|(}})/, '`')
"> #{line}"
end.join("\n")

description = safe_description(issue.description)
query.merge! subject: issue.summary, :"pull_request[title]" => title

if (headline.length + description.length) > SAFE_QUERY_STRING_SIZE
Expand All @@ -149,6 +145,16 @@ class App < Git::Whistles::App
end
end

def safe_description(description)
return '' unless description

description.split("\n").map do |line|
(1..6).each { |i| line.gsub!(/(h#{i}.)/, '#' * i) }
line.gsub!(/({{)|(}})/, '`')
"> #{line}"
end.join("\n")
end

def launch_browser(url)
BROWSERS.each do |command|
next if run("which #{command}").strip.empty?
Expand Down

0 comments on commit 5745fc3

Please sign in to comment.