Created
January 21, 2014 20:16
-
-
Save pedrospdc/8547529 to your computer and use it in GitHub Desktop.
Git flow hook to fetch/merge/name a hotfix/release.
Requires Git Flow AVH edition (https://github.com/petervanderdoes/gitflow)
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 | |
| # | |
| # Runs during git flow hotfix start | |
| # | |
| # Positional arguments: | |
| # $1 Version | |
| # | |
| # Return VERSION - When VERSION is returned empty, git-flow will stop as the | |
| # version is necessary | |
| # | |
| # The following variables are available as they are exported by git-flow: | |
| # | |
| # MASTER_BRANCH - The branch defined as Master | |
| # DEVELOP_BRANCH - The branch defined as Develop | |
| $version = ARGV[0] | |
| if $version.nil? | |
| `git fetch -p` | |
| list = [ENV['MASTER_BRANCH'], ENV['DEVELOP_BRANCH']] | |
| list.each do |x| | |
| `git checkout #{x}` | |
| `git merge origin/#{x}` | |
| end | |
| last_tag_rev = `git rev-list --tags --max-count=1`.strip | |
| last_tag_name = `git describe --tags #{last_tag_rev}`.strip | |
| major, minor, hotfix = last_tag_name.split('.').map(&:to_i) | |
| $version = "%d.%d.%d" % [major, minor, hotfix + 1] | |
| end | |
| puts $version |
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 | |
| # | |
| # Runs during git flow hotfix start | |
| # | |
| # Positional arguments: | |
| # $1 Version | |
| # | |
| # Return VERSION - When VERSION is returned empty, git-flow will stop as the | |
| # version is necessary | |
| # | |
| # The following variables are available as they are exported by git-flow: | |
| # | |
| # MASTER_BRANCH - The branch defined as Master | |
| # DEVELOP_BRANCH - The branch defined as Develop | |
| $version = ARGV[0] | |
| if $version.nil? | |
| `git fetch -p` | |
| list = [ENV['MASTER_BRANCH'], ENV['DEVELOP_BRANCH']] | |
| list.each do |x| | |
| `git checkout #{x}` | |
| `git merge origin/#{x}` | |
| end | |
| last_tag_rev = `git rev-list --tags --max-count=1`.strip | |
| last_tag_name = `git describe --tags #{last_tag_rev}`.strip | |
| major, minor, hotfix = last_tag_name.split('.').map(&:to_i) | |
| $version = "%d.%d.%d" % [major, minor + 1, hotfix] | |
| end | |
| puts $version |
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
| # Append this to your ~/.gitconfig | |
| [init] | |
| templatedir = ~/.git-templates | |
| # Place the other two files inside ~/.git-templates/hooks/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment