Created
November 17, 2014 22:59
-
-
Save tonekk/c5143838b154fc81dfac 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
#!/bin/sh | |
export GIT_MERGE_AUTOEDIT=no | |
ruby 'bin/hotfix.rb' | |
unset GIT_MERGE_AUTOEDIT |
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
current_branch = `git rev-parse --abbrev-ref HEAD` | |
# Check if we are already on a hotfix branch | |
if (current_branch =~ /hotfix/).nil? | |
##################### | |
# Hotfix start flow | |
##################### | |
version = File.read('VERSION').scan(/(\d+)\.(\d+)\.(\d+)/)[0] | |
hotfix = Integer(version[2]) + 1 | |
new_version = "#{version[0]}.#{version[1]}.#{hotfix}" | |
if system("git flow hotfix start #{new_version}") | |
# Bump version | |
File.open('VERSION', 'w'){|f| f.write(new_version)} | |
system('git add VERSION') | |
system("git commit -m'bumps version to #{new_version}'") | |
end | |
else | |
##################### | |
# Hotfix finish flow | |
##################### | |
# Use last commit message as tag message | |
last_commit_message = `git log -1 --pretty=%B`.gsub("\n", '') | |
last_commit_message.gsub!(' ', '_') | |
version = current_branch.scan(/hotfix\/(.+)/)[0][0] | |
if system("git flow hotfix finish -m '#{last_commit_message}' '#{version}'") | |
system('git push --all && git push --tags') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create
Hotfixes
even faster with Git Flow and this script.Put e.g. in your
rails/bin
directory (framework dependant), put execute rights onhotfix
and thenbin/hotfix
to start and end a hotfix.The script assumes you have a file named
VERSION
in your projects directory.Edit accordingly