Created
August 4, 2016 07:33
-
-
Save kibitan/4cca027717b5c61403ecdae435579e89 to your computer and use it in GitHub Desktop.
.git/hooks/commit-msg: git commit hook that auto adding message of associating issue and rollbar error issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
current_branch = `git symbolic-ref --short HEAD` | |
if /^iss-(\d+).*/ =~ current_branch | |
commit_msgs = File.readlines(ARGV[0]) | |
issue_id = $1 | |
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 "refs ##{issue_id} " if %r(##{issue_id}) !~ commit_msgs.join() | |
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