Created
August 11, 2015 22:55
-
-
Save thexavismith/f6574241aa4cca19ba27 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 | |
message_file = ARGV[0] | |
original_message = File.read(message_file) | |
current_branch = `git rev-parse --abbrev-ref HEAD` | |
story_number_regex = /[a-zA-Z]+-[0-9]+/ | |
regex_match = current_branch.match(story_number_regex) | |
message_match = original_message.match(story_number_regex) | |
message = if regex_match | |
if message_match | |
original_message | |
else | |
story_number = regex_match[0].upcase | |
"#{story_number} #{original_message}" | |
end | |
else | |
original_message | |
end | |
File.open(message_file, 'w') { |f| f.write message } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment