Permalink
Browse files

Add some example hook scripts.

  • Loading branch information...
1 parent 359db20 commit 9283eaef814806efe98cec9f8ef11ed47d6a4cd5 @nvie committed Jan 2, 2012
View
@@ -211,11 +211,15 @@ cmd_start() {
require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
fi
+ run_pre_hook "$NAME" "$ORIGIN" "$BRANCH" "$BASE"
+
# create branch
if ! git checkout -b "$BRANCH" "$BASE"; then
die "Could not create feature branch '$BRANCH'"
fi
+ run_post_hook "$NAME" "$ORIGIN" "$BRANCH" "$BASE"
+
echo
echo "Summary of actions:"
echo "- A new branch '$BRANCH' was created, based on '$BASE'"
@@ -296,6 +300,8 @@ cmd_finish() {
require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
fi
+ run_pre_hook "$NAME" "$ORIGIN" "$BRANCH"
+
# if the user wants to rebase, do that first
if flag rebase; then
if ! git flow feature rebase "$NAME" "$DEVELOP_BRANCH"; then
@@ -331,6 +337,8 @@ cmd_finish() {
exit 1
fi
+ run_post_hook "$NAME" "$ORIGIN" "$BRANCH"
+
# when no merge conflict is detected, just clean up the feature branch
helper_finish_cleanup
}
@@ -377,6 +385,8 @@ cmd_publish() {
git fetch -q "$ORIGIN"
require_branch_absent "$ORIGIN/$BRANCH"
+ run_pre_hook "$NAME" "$ORIGIN" "$BRANCH"
+
# create remote branch
git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
git fetch -q "$ORIGIN"
@@ -386,6 +396,8 @@ cmd_publish() {
git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
git checkout "$BRANCH"
+ run_post_hook "$NAME" "$ORIGIN" "$BRANCH"
+
echo
echo "Summary of actions:"
echo "- A new remote branch '$BRANCH' was created"
@@ -401,12 +413,17 @@ cmd_track() {
# sanity checks
require_clean_working_tree
require_branch_absent "$BRANCH"
+
+ run_pre_hook "$NAME" "$ORIGIN" "$BRANCH"
+
git fetch -q "$ORIGIN"
require_branch "$ORIGIN/$BRANCH"
# create tracking branch
git checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
+ run_post_hook "$NAME" "$ORIGIN" "$BRANCH"
+
echo
echo "Summary of actions:"
echo "- A new remote tracking branch '$BRANCH' was created"
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Ran before git flow feature finish
+#
+# Positional arguments:
+# $1 The friendly name of the branch
+# $2 The origin remote
+# $3 The full branch name (including the feature prefix)
+#
+NAME=$1
+ORIGIN=$2
+BRANCH=$3
+
+# Implement your script here.
+# To terminate the git-flow action, return a non-zero exit code.
+exit 0
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Ran before git flow feature publish
+#
+# Positional arguments:
+# $1 The friendly name of the branch
+# $2 The origin remote
+# $3 The full branch name (including the feature prefix)
+#
+NAME=$1
+ORIGIN=$2
+BRANCH=$3
+
+# Implement your script here.
+# To terminate the git-flow action, return a non-zero exit code.
+exit 0
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Ran before git flow feature pull.
+#
+# Positional arguments:
+# $1 The friendly name of the branch
+# $2 The remote to pull from
+# $3 The full branch name (including the feature prefix)
+#
+NAME=$1
+REMOTE=$2
+BRANCH=$3
+
+# Implement your script here.
+# To terminate the git-flow action, return a non-zero exit code.
+exit 0
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# Ran before git flow feature start
+#
+# Positional arguments:
+# $1 The friendly name of the branch
+# $2 The origin remote
+# $3 The full branch name (including the feature prefix)
+# $4 The base from which this feature is started
+#
+NAME=$1
+ORIGIN=$2
+BRANCH=$3
+BASE=$4
+
+# Implement your script here.
+# To terminate the git-flow action, return a non-zero exit code.
+exit 0
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Ran before git flow feature track
+#
+# Positional arguments:
+# $1 The friendly name of the branch
+# $2 The origin remote
+# $3 The full branch name (including the feature prefix)
+#
+NAME=$1
+ORIGIN=$2
+BRANCH=$3
+
+# Implement your script here.
+# To terminate the git-flow action, return a non-zero exit code.
+exit 0

0 comments on commit 9283eae

Please sign in to comment.