Last active
December 22, 2021 20:07
-
-
Save lukebergen/7eb9dd779c7c5e99ef328959ca73ef30 to your computer and use it in GitHub Desktop.
Git commit message hook for reviewed clubhouse
This file contains 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 | |
# Automatically adds clubhouse id and link to commit messages based on branch name | |
file = ARGV[0] | |
branch_path = `git symbolic-ref -q HEAD`.split("\n")[0] # Somthing like refs/heads/myBranchName | |
branch_name = branch_path.split("/").last | |
chid = branch_name.split("-").last.gsub(/ch/i, '') | |
non_ammend = `head -n1 #{file}` == "\n" | |
if chid.to_i.to_s == chid && non_ammend | |
original = File.read(file) | |
text = "CH#{chid}\n\n[CH#{chid}](https://app.clubhouse.io/reviewed/story/#{chid})\n#{original}" | |
File.open(file, "w+") do |f| | |
f.write(text) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment