-
-
Save urfolomeus/6915666 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] || `git log --format=%B -1`.strip | |
action = ARGV[0].nil? '--amend' : '' | |
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 #{action} -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