Skip to content

Instantly share code, notes, and snippets.

@kibitan
Last active August 26, 2016 03:26
Show Gist options
  • Save kibitan/69b892e2b50ef35fbcb77a6e296f3c46 to your computer and use it in GitHub Desktop.
Save kibitan/69b892e2b50ef35fbcb77a6e296f3c46 to your computer and use it in GitHub Desktop.
.git/hooks/commit-msg: git commit hook for associating to rollbar error
#!/usr/bin/env ruby
current_branch = `git symbolic-ref --short HEAD`
# ブランチ名が iss-{Github Issue ID} の場合
if /^iss-(\d+).*/ =~ current_branch
issue_id = $1
commit_msgs = File.readlines(ARGV[0])
puts 'setup `ghi` command via https://github.com/stephencelis/ghi' unless system('which ghi > /dev/null 2>&1')
%r{https://rollbar.com/.+/items/(\d+)} =~ `ghi show #{issue_id}`
rollbar_item_id = $1
open(ARGV[0], 'w') do |file|
file.print "fixed rb##{rollbar_item_id} " if rollbar_item_id && %r(##{rollbar_item_id}) !~ commit_msgs.join()
file.puts commit_msgs
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment