Skip to content

Instantly share code, notes, and snippets.

@urfolomeus
Forked from mconnell/custom_amend.rb
Last active December 25, 2015 04:09
Show Gist options
  • Save urfolomeus/6915666 to your computer and use it in GitHub Desktop.
Save urfolomeus/6915666 to your computer and use it in GitHub Desktop.
#!/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}"`
#!/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}"`
#!/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