Permalink
Browse files

Be git-describe friendly.

This patch tags commits on the original (release/hotfix branch) instead
of tagging the merge commit on the master branch.  This keeps the
history git-describe friendly.  (For related discussions, see #49, #85,
  • Loading branch information...
2 parents afb191f + aec4818 commit aa93d2346f840e16a05c6546e1e22c1dddfbc997 @nvie committed Jul 9, 2012
Showing with 97 additions and 32 deletions.
  1. +1 −0 AUTHORS
  2. +1 −1 README.mdown
  3. +1 −0 contrib/msysgit-install.cmd
  4. +4 −1 git-flow
  5. +16 −7 git-flow-feature
  6. +30 −5 git-flow-hotfix
  7. +7 −1 git-flow-init
  8. +30 −12 git-flow-release
  9. +7 −5 git-flow-support
View
1 AUTHORS
@@ -19,5 +19,6 @@ Authors are (ordered by first commit date):
- Emre Berge Ergenekon
- Eric Holmes
- Vedang Manerikar
+- Myke Hines
Portions derived from other open source works are clearly marked.
View
2 README.mdown
@@ -138,7 +138,7 @@ Showing your appreciation
A few people already requested it, so now it's here: a Flattr button.
Of course, the best way to show your appreciation for the original
-[blog post](http://nvie.com/git-model) or the git-flow tool itself remains
+[blog post](http://nvie.com/posts/a-successful-git-branching-model/) or the git-flow tool itself remains
contributing to the community. If you'd like to show your appreciation in
another way, however, consider Flattr'ing me:
View
1 contrib/msysgit-install.cmd
@@ -63,6 +63,7 @@ goto :End
:ChkGetopt
:: %1 is getopt.exe
if exist "%GIT_HOME%\bin\%1" goto :EOF
+if exist "%USERPROFILE%\bin\%1" goto :EOF
if exist "%~f$PATH:1" goto :EOF
echo %GIT_HOME%\bin\%1 not found.>&2
echo You have to install this file manually. See the GitFlow README.
View
5 git-flow
@@ -109,7 +109,10 @@ main() {
fi
# run the specified action
- cmd_$SUBACTION "$@"
+ if [ $SUBACTION != "help" ]; then
+ init
+ fi
+ cmd_$SUBACTION "$@"
}
main "$@"
View
23 git-flow-feature
@@ -36,15 +36,17 @@
# policies, either expressed or implied, of Vincent Driessen.
#
-require_git_repo
-require_gitflow_initialized
-gitflow_load_settings
-PREFIX=$(git config --get gitflow.prefix.feature)
+init() {
+ require_git_repo
+ require_gitflow_initialized
+ gitflow_load_settings
+ PREFIX=$(git config --get gitflow.prefix.feature)
+}
usage() {
echo "usage: git flow feature [list] [-v]"
echo " git flow feature start [-F] <name> [<base>]"
- echo " git flow feature finish [-rFkD] [<name|nameprefix>]"
+ echo " git flow feature finish [-rFkDS] [<name|nameprefix>]"
echo " git flow feature publish <name>"
echo " git flow feature track <name>"
echo " git flow feature diff [<name|nameprefix>]"
@@ -232,6 +234,7 @@ cmd_finish() {
DEFINE_boolean rebase false "rebase instead of merge" r
DEFINE_boolean keep false "keep branch after performing finish" k
DEFINE_boolean force_delete false "force delete feature branch after finish" D
+ DEFINE_boolean squash false "squash feature during merge" S
parse_args "$@"
expand_nameprefix_arg_or_current
@@ -312,7 +315,13 @@ cmd_finish() {
if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
git merge --ff "$BRANCH"
else
- git merge --no-ff "$BRANCH"
+ if noflag squash; then
+ git merge --no-ff "$BRANCH"
+ else
+ git merge --squash "$BRANCH"
+ git commit
+ git merge "$BRANCH"
+ fi
fi
if [ $? -ne 0 ]; then
@@ -507,7 +516,7 @@ cmd_pull() {
exit 1
fi
else
- it pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'."
+ git pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'."
fi
echo "Pulled $REMOTE's changes into $BRANCH."
View
35 git-flow-hotfix
@@ -36,17 +36,20 @@
# policies, either expressed or implied, of Vincent Driessen.
#
-require_git_repo
-require_gitflow_initialized
-gitflow_load_settings
-VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
-PREFIX=$(git config --get gitflow.prefix.hotfix)
+init() {
+ require_git_repo
+ require_gitflow_initialized
+ gitflow_load_settings
+ VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
+ PREFIX=$(git config --get gitflow.prefix.hotfix)
+}
usage() {
echo "usage: git flow hotfix [list] [-v]"
echo " git flow hotfix start [-F] <version> [<base>]"
echo " git flow hotfix finish [-Fsumpk] <version>"
echo " git flow hotfix publish <version>"
+ echo " git flow hotfix track <version>"
}
cmd_default() {
@@ -216,11 +219,32 @@ cmd_publish() {
echo
}
+cmd_track() {
+ parse_args "$@"
+ require_version_arg
+
+ # sanity checks
+ require_clean_working_tree
+ require_branch_absent "$BRANCH"
+ git fetch -q "$ORIGIN"
+ require_branch "$ORIGIN/$BRANCH"
+
+ # create tracking branch
+ git checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new remote tracking branch '$BRANCH' was created"
+ echo "- You are now on branch '$BRANCH'"
+ echo
+}
+
cmd_finish() {
DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
DEFINE_boolean sign false "sign the release tag cryptographically" s
DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
DEFINE_string message "" "use the given tag message" m
+ DEFINE_string messagefile "" "use the contents of the given file as tag message" f
DEFINE_boolean push false "push to $ORIGIN after performing finish" p
DEFINE_boolean keep false "keep branch after performing finish" k
DEFINE_boolean notag false "don't tag this release" n
@@ -269,6 +293,7 @@ cmd_finish() {
flag sign && opts="$opts -s"
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
+ [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
eval git tag $opts "$VERSION_PREFIX$VERSION" "$BRANCH" || \
die "Tagging failed. Please run finish again to retry."
fi
View
8 git-flow-init
@@ -153,11 +153,17 @@ cmd_default() {
default_suggestion=
for guess in $(git config --get gitflow.branch.develop) \
'develop' 'int' 'integration' 'master'; do
- if git_local_branch_exists "$guess"; then
+ if git_local_branch_exists "$guess" && [ "$guess" != "$master_branch" ]; then
default_suggestion="$guess"
break
fi
done
+
+ if [ -z $default_suggestion ]; then
+ should_check_existence=NO
+ default_suggestion=$(git config --get gitflow.branch.develop || echo develop)
+ fi
+
fi
printf "Branch name for \"next release\" development: [$default_suggestion] "
View
42 git-flow-release
@@ -36,16 +36,18 @@
# policies, either expressed or implied, of Vincent Driessen.
#
-require_git_repo
-require_gitflow_initialized
-gitflow_load_settings
-VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
-PREFIX=$(git config --get gitflow.prefix.release)
+init() {
+ require_git_repo
+ require_gitflow_initialized
+ gitflow_load_settings
+ VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
+ PREFIX=$(git config --get gitflow.prefix.release)
+}
usage() {
echo "usage: git flow release [list] [-v]"
echo " git flow release start [-F] <version> [<base>]"
- echo " git flow release finish [-Fsumpk] <version>"
+ echo " git flow release finish [-FsumpkS] <version>"
echo " git flow release publish <name>"
echo " git flow release track <name>"
}
@@ -190,9 +192,11 @@ cmd_finish() {
DEFINE_boolean sign false "sign the release tag cryptographically" s
DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
DEFINE_string message "" "use the given tag message" m
+ DEFINE_string messagefile "" "use the contents of the given file as a tag message" f
DEFINE_boolean push false "push to $ORIGIN after performing finish" p
DEFINE_boolean keep false "keep branch after performing finish" k
DEFINE_boolean notag false "don't tag this release" n
+ DEFINE_boolean squash false "squash release during merge" S
parse_args "$@"
require_version_arg
@@ -224,9 +228,15 @@ cmd_finish() {
if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
git checkout "$MASTER_BRANCH" || \
die "Could not check out $MASTER_BRANCH."
- git merge --no-ff "$BRANCH" || \
- die "There were merge conflicts."
- # TODO: What do we do now?
+ if noflag squash; then
+ git merge --no-ff "$BRANCH" || \
+ die "There were merge conflicts."
+ # TODO: What do we do now?
+ else
+ git merge --squash "$BRANCH" || \
+ die "There were merge conflicts."
+ git commit
+ fi
fi
if noflag notag; then
@@ -239,6 +249,7 @@ cmd_finish() {
flag sign && opts="$opts -s"
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
+ [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
eval git tag $opts "$tagname" "$BRANCH" || \
die "Tagging failed. Please run finish again to retry."
fi
@@ -253,9 +264,16 @@ cmd_finish() {
# TODO: Actually, accounting for 'git describe' pays, so we should
# ideally git merge --no-ff $tagname here, instead!
- git merge --no-ff "$BRANCH" || \
- die "There were merge conflicts."
- # TODO: What do we do now?
+ if noflag squash; then
+ git merge --no-ff "$BRANCH" || \
+ die "There were merge conflicts."
+ # TODO: What do we do now?
+ else
+ git merge --squash "$BRANCH" || \
+ die "There were merge conflicts."
+ # TODO: What do we do now?
+ git commit
+ fi
fi
# delete branch
View
12 git-flow-support
@@ -36,11 +36,13 @@
# policies, either expressed or implied, of Vincent Driessen.
#
-require_git_repo
-require_gitflow_initialized
-gitflow_load_settings
-VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
-PREFIX=$(git config --get gitflow.prefix.support)
+init() {
+ require_git_repo
+ require_gitflow_initialized
+ gitflow_load_settings
+ VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
+ PREFIX=$(git config --get gitflow.prefix.support)
+}
warn "note: The support subcommand is still very EXPERIMENTAL!"
warn "note: DO NOT use it in a production situation."

0 comments on commit aa93d23

Please sign in to comment.