Skip to content

Instantly share code, notes, and snippets.

@pallan pallan/gist:4001241
Created Nov 2, 2012

What would you like to do?
Commit-msg hook to prefix with a Chiliproject (Redmine) ID
#!/usr/bin/env ruby
current_branch =`git symbolic-ref HEAD`.chomp.split('/').last
issue_id = current_branch[/\d+/].to_i
commit_message =
matches = /^[rmRM\s-]*#\d*(.*)$/.match(commit_message)
commit_message = matches[1].strip if matches
if commit_message == ''
puts "Aborting commit due to empty commit message."
exit 1
commit_message = "RM ##{issue_id} #{commit_message}" unless issue_id == 0, 'w') {|f| f.puts commit_message }

This comment has been minimized.

Copy link
Owner Author

pallan commented Nov 2, 2012

There a probably a lot of edge cases that I am missing here, however, it covers the majority of cases my team has to deal with. Therefore I deem it "good enough". :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.