Skip to content

Instantly share code, notes, and snippets.

Created March 13, 2014 01:05
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hlindberg/9520023 to your computer and use it in GitHub Desktop.
Script to match puppet tickets from git log with list from jira
# This script mangles the output from git log between two git references
# and matches this with a list of tickets from Jira.
# The List from Jira can be obtained by showing the list of issues for a release
# i.e. a query like this for the given release which gets all targeting the
# release in question:
# project = PUP AND fixVersion = "3.5.0" ORDER BY key ASC
# Then removing all columns from the output except key.
# (This is done by selecting columns in the menu far right above the list)
# Then exporting it to Excel, and then from Excel to a CSV
# the CVS will be in MS format with \r instead of \n, change that by
# running:
# tr '\r' '\n' < the_file.csv > jiraissues.txt
# Then edit the jiraissues.txt to remove the header and footer lines
# Then change the from and to in this script to the tags you want to
# compare
# You must cd to the puppet get repo for this to work, and place
# the extra files there as well.
from = "3.4.3"
to = "master"
# Get the log from git
# process and store in a hash per user entered ticket reference
result = {|h, k| h[k] = [] }
a = %x{git log --no-merges --oneline #{from}..#{to}}
a.each_line do |line|
m = line.match(/^([0-9a-fA-F]+)\s+(\([^\)]*\))?(.*)$/)
result[(m[2] || 'unmarked').upcase] << [m[1], m[3]]
# Process file with Jira issues
jiratext ='jiraissues.txt')
known_issues = jiratext.each_line.reduce({}) {|memo, line| memo["(#{line.chomp})"] = true; memo }
# Print list of ssues sorted, for each show sha + comment after reference
result.keys.sort.each do |k|
if known_issues[k]
marker = '--'
known_issues[k] = :in_git
marker = '**'
puts "#{marker} #{k.upcase}"
v = result[k]
v.each do | data |
puts " #{data[0]} #{data[1]}"
puts "---"
puts {|k,v| v != :in_git }.keys.join("\n")
Copy link

This looks fun.

Any issue with dumping away the (maint) commits prior to comparison?

Copy link

Finding my way from here to the Jira curl -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment