Skip to content

Instantly share code, notes, and snippets.

@pgblu
Last active November 6, 2019 15:22
Show Gist options
  • Save pgblu/ad72d22bf4228cacd658c3e9000390d5 to your computer and use it in GitHub Desktop.
Save pgblu/ad72d22bf4228cacd658c3e9000390d5 to your computer and use it in GitHub Desktop.
# Usage: ruby commit-prepender this is my commit message without quotation marks
branch_name = %x.git rev-parse --abbrev-ref HEAD.
regex = Regexp.new(/[A-Z]*-[0-9]*/)
string_to_prepend = branch_name.match(regex).to_s
cmd = "git commit -m \"[#{string_to_prepend}] #{ARGV.join(" ")}\""
`#{cmd} >&2`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment