Skip to content

Instantly share code, notes, and snippets.

@carld
Created September 7, 2016 00:23
Show Gist options
  • Save carld/b42c8c15a88c2678b0b0efa55ad66067 to your computer and use it in GitHub Desktop.
Save carld/b42c8c15a88c2678b0b0efa55ad66067 to your computer and use it in GitHub Desktop.
pleasant lawyer git hook prepare-commit-msg, .git/hooks/prepare-commit-msg
#!/usr/bin/env ruby
require 'pleasant_lawyer'
git_branch_name = `git symbolic-ref -q HEAD`
branch_name = File.basename(git_branch_name).gsub(/_/," ")
file = File.open(ARGV[0], 'r')
contents = file.read
file.close
File.open(ARGV[0], 'w') do |file|
file.write("B##{PleasantLawyer.convert(branch_name)} ") if branch_name.split(/ /).length == 2
file.write(contents)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment