Last active
August 26, 2016 03:26
-
-
Save kibitan/69b892e2b50ef35fbcb77a6e296f3c46 to your computer and use it in GitHub Desktop.
.git/hooks/commit-msg: git commit hook for associating to rollbar error
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` | |
# ブランチ名が 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