Created
April 23, 2019 10:30
-
-
Save thegeorgeous/cdf59119b92cf77fd624ef9e09bedea2 to your computer and use it in GitHub Desktop.
Commit hook to pick the ticket number from branch name and append it to git log summary
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 | |
branch_name = `git symbolic-ref --short HEAD` | |
if !File.read(ARGV[0]).match?(/fixup!|squash!|\[WIP\]|\[\d+\]/) && branch_name.match?(/\d+/) | |
story_number = branch_name.match(/\d+/)[0] | |
if story_number | |
lines = File.readlines(ARGV[0]) | |
lines[0] = "[#{story_number}] " + lines[0] | |
File.open(ARGV[0], 'w') { |f| f.write(lines.join) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment