Created
April 15, 2014 19:51
-
-
Save zph/10765471 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| branch_name = `git rev-parse --abbrev-ref HEAD`.chomp | |
| DIVIDERS = %r{[-|_|/|\/]} | |
| parts = branch_name.match(/(?<initials>.+)#{DIVIDERS}(?<number>\d{5,})#{DIVIDERS}(?<description>.*)/) | |
| begin | |
| INITIALS = parts[:initials].split(DIVIDERS).join("/").upcase | |
| PIVOTAL_NUMBER = parts[:number] | |
| DESCRIPTION = parts[:description].gsub(/#{DIVIDERS}/, ' ') | |
| rescue | |
| exit(0) | |
| end | |
| commit_message = <<MSG | |
| [#{INITIALS}] [#{PIVOTAL_NUMBER}] #{DESCRIPTION} | |
| Pivotal Story: https://www.pivotaltracker.com/story/show/#{PIVOTAL_NUMBER} | |
| MSG | |
| STDOUT << commit_message |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TC_ZH_999999_stuff_and_description
TC/ZH/999999_stuff_and_sstuff