From 5745fc3ca14ca7bb64c48f954f16dd2f765fcfc8 Mon Sep 17 00:00:00 2001 From: Zhivko Draganov Date: Fri, 13 May 2016 11:47:20 +0300 Subject: [PATCH] Do not fail on blank Jira issue description --- bin/git-jira-pr | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/git-jira-pr b/bin/git-jira-pr index 2e52926..450f706 100755 --- a/bin/git-jira-pr +++ b/bin/git-jira-pr @@ -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 @@ -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?