Created
October 10, 2013 09:31
-
-
Save mconnell/6915616 to your computer and use it in GitHub Desktop.
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 | |
## | |
# script to amend a commit which should be been created with the previous script | |
## | |
commit_message = `git log --format=%B -1`.strip | |
branch_name = `git rev-parse --abbrev-ref HEAD`.strip | |
matches = branch_name.match (/\w\-(\d+)\Z/i) | |
pivotal_story_id = matches ? matches[-1] : nil | |
commit_message = "[##{pivotal_story_id}] #{commit_message}" if pivotal_story_id | |
`git commit --amend -m "#{commit_message}"` |
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 | |
## | |
# script to prepend a commit with [#story-id] if the branch is suffixed with the story-id | |
## | |
commit_message = ARGV[0] | |
branch_name = `git rev-parse --abbrev-ref HEAD`.strip | |
matches = branch_name.match (/\w\-(\d+)\Z/i) | |
pivotal_story_id = matches ? matches[-1] : nil | |
commit_message = "[##{pivotal_story_id}] #{commit_message}" if pivotal_story_id | |
`git commit -m "#{commit_message}"` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To explain this script:
Working on a codebase where branches are labeled "some_branch_name-123435" and 12345 is a pivotal story id.
These scripts allow me to write a commit message as I normally would, and it will then prefix each commit message so I end up with "[#12345] original comment here".