Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop'

  • Loading branch information...
commit cbdd531dce680bce8033eb0bd99028d9e807df4f 2 parents 1ffb6b1 + e6e46ce
Adriaan Erasmus authored
View
4 .gitignore
@@ -0,0 +1,4 @@
+debian/files
+debian/*.substvars
+debian/*.debhelper.log
+debian/*/*
View
9 AUTHORS
@@ -11,5 +11,14 @@ Authors are (ordered by first commit date):
- Felipe Talavera
- Guillaume-Jean Herbiet
- Joseph A. Levin
+- Jannis Leidel
+- Konstantin Tjuterev
+- Kiall Mac Innes
+- Jon Bernard
+- Olivier Mengué
+- Emre Berge Ergenekon
+- Eric Holmes
+- Vedang Manerikar
+- Myke Hines
Portions derived from other open source works are clearly marked.
View
35 Changes.mdown
@@ -1,3 +1,38 @@
+0.4.3:
+-----
+Release: **not yet**
+
+* Added `git flow project` based on `git flow feature` for branches that
+ typically lives longer than 1 day.
+
+* Changes `git flow feature finish` to accept a base branch in order to finish
+ features initially created from a project branch.
+
+* Cahnged `git flow init` to ask the user what the project branches prefixes should
+ be called.
+
+
+0.4.2:
+-----
+Release date: **not yet**
+
+* `git flow init` now detects situations where origin already has gitflow
+ branches set up, and behaves accordingly (thanks Emre Berge Ergenekon).
+
+* `git flow feature finish` can now be called without a feature branch
+ name(prefix) argument and will finish the current branch, if on any.
+
+* `git flow feature pull` now has a `-r` flag, to support `pull --rebase`
+ semantics (thanks Vedang Manerikar).
+
+* Various minor bug fixes related to internal argument passing.
+
+* Improved some documentation.
+
+* Better support for Windows and BSD users.
+
+* Add package installer for the Windows platform.
+
0.4.1:
-----
Release date: **2011/02/04**
View
1  Makefile
@@ -26,6 +26,7 @@
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of Vincent Driessen.
#
+
prefix=/usr/local
# files that need mode 755
View
110 README.mdown
@@ -1,5 +1,6 @@
-git-flow ![Project status](http://stillmaintained.com/nvie/gitflow.png)
+git-flow
========
+
A collection of Git extensions to provide high-level repository operations
for Vincent Driessen's [branching model](http://nvie.com/git-model "original
blog post").
@@ -14,86 +15,14 @@ Kreeftmeijer's blog post:
Or have a look at one of these screen casts:
+* [How to use a scalable Git branching model called git-flow](http://buildamodule.com/video/change-management-and-version-control-deploying-releases-features-and-fixes-with-git-how-to-use-a-scalable-git-branching-model-called-gitflow) (by Build a Module)
* [A short introduction to git-flow](http://vimeo.com/16018419) (by Mark Derricutt)
* [On the path with git-flow](http://codesherpas.com/screencasts/on_the_path_gitflow.mov) (by Dave Bock)
Installing git-flow
-------------------
-
-### Mac OS
-If you're on a Mac and use [homebrew](http://github.com/mxcl/homebrew), it's simple:
-
- $ brew install git-flow
-
-If you're on a Mac and use [MacPorts](http://macports.org/), it's simple:
-
- $ port install git-flow
-
-### Linux, etc.
-Another easy way to install git-flow is using Rick Osborne's excellent git-flow
-installer, which can be run using the following command:
-
- $ wget --no-check-certificate -q -O - https://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | sudo sh
-
-### Windows
-#### Using Cygwin
-For Windows users who wish to use the automated install, it is suggested that you install [Cygwin](http://www.cygwin.com/)
-first to install tools like `git`, `util-linux` and `wget` (with those three being packages that can be selected
-during installation). Then simply run this command from a Cygwin shell:
-
- $ wget -q -O - https://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | sh
-
-#### Using msysgit
-This is much like the manual installation below, but there are additional steps required to install some extra tools that
-are not distributed with [msysgit](http://code.google.com/p/msysgit/).
-
-Clone the git-flow sources from Github:
-
- $ git clone --recursive git://github.com/nvie/gitflow.git
-
-Copy git-flow's relevant files to your msysgit installation directory:
-
- $ mkdir /usr/local/bin
- $ cp git-flow* gitflow* /usr/local/bin/
- $ cp shFlags/src/shflags /usr/local/bin/gitflow-shFlags
-
-Next up we need to borrow a couple of binaries from [Cygwin](http://www.cygwin.com/). If you don't have Cygwin installed, please
-install it including the `util-linux` package. Apart from `util-linux`'s dependencies, no other packages are required. When you
-finished installation, copy the following files using msysgit's _Git Bash_. We assume the Cygwin's default installation path in C:\cygwin.
-
- $ cd /c/cygwin/
- $ cp bin/getopt.exe /usr/local/bin/
- $ cp bin/cyggcc_s-1.dll /usr/local/bin/
- $ cp bin/cygiconv-2.dll /usr/local/bin/
- $ cp bin/cygintl-8.dll /usr/local/bin/
- $ cp bin/cygwin1.dll /usr/local/bin/
-
-After copying the files above, you can safely uninstall your Cygwin installation by deleting the C:\cygwin directory.
-
-### Manual installation
-If you prefer a manual installation, please use the following instructions:
-
- $ git clone --recursive git://github.com/nvie/gitflow.git
-
-Then, you can install `git-flow`, using:
-
- $ sudo make install
-
-By default, git-flow will be installed in /usr/local. To change the prefix
-where git-flow will be installed, simply specify it explicitly, using:
-
- $ sudo make prefix=/opt/local install
-
-Or simply point your `PATH` environment variable to your git-flow checkout
-directory.
-
-*Installation note:*
-git-flow depends on the availability of the command line utility `getopt`,
-which may not be available in your Unix/Linux environment. Please use your
-favorite package manager to install `getopt`. For Cygwin, install the
-`util-linux` package to get `getopt`. If you use `apt-get` as your install
-manager, the package name is `opt`.
+See the Wiki for up-to-date [Installation Instructions](https://github.com/nvie/gitflow/wiki/Installation).
Integration with your shell
@@ -104,9 +33,6 @@ For those who use the [Bash](http://www.gnu.org/software/bash/) or
by [bobthecow](http://github.com/bobthecow). It offers tab-completion for all
git-flow subcommands and branch names.
-For Windows users, [msysgit](http://code.google.com/p/msysgit/) is a good
-starting place for installing git.
-
FAQ
---
@@ -127,6 +53,23 @@ contributors, please see the [AUTHORS](AUTHORS) file.
Any questions, tips, or general discussion can be posted to our Google group:
[http://groups.google.com/group/gitflow-users](http://groups.google.com/group/gitflow-users)
+Contributing
+------------
+Fork the repository. Then, run:
+
+ git clone --recursive git@github.com:<username>/gitflow.git
+ cd gitflow
+ git branch master origin/master
+ git flow init -d
+ git flow feature start <your feature>
+
+Then, do work and commit your changes. **Hint**: ``export PATH=`pwd`:$PATH``
+from within the gitflow directory makes sure you're using the version of
+gitflow you're currently developing.
+
+ git flow feature publish <your feature>
+
+When done, open a pull request to your feature branch.
License terms
-------------
@@ -141,13 +84,15 @@ in a Github fork, of course.
To initialize a new repo with the basic branch structure, use:
- git flow init
+ git flow init [-d]
This will then interactively prompt you with some questions on which branches
you would like to use as development and production branches, and how you
would like your prefixes be named. You may simply press Return on any of
those questions to accept the (sane) default suggestions.
+The ``-d`` flag will accept all defaults.
+
### Creating feature/release/hotfix/support branches
@@ -159,6 +104,11 @@ those questions to accept the (sane) default suggestions.
For feature branches, the `<base>` arg must be a commit on `develop`.
+* To push/pull a feature branch to the remote repository, use:
+
+ git flow feature publish <name>
+ git flow feature pull <remote> <name>
+
* To list/start/finish release branches, use:
git flow release
@@ -188,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
4 contrib/gitflow-installer.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# git-flow make-less installer for *nix systems, by Rick Osborne
# Based on the git-flow core Makefile:
@@ -50,7 +50,7 @@ case "$1" in
;;
*)
echo "Installing git-flow to $INSTALL_PREFIX"
- if [[ -d "$REPO_NAME" && -d "$REPO_NAME/.git" ]] ; then
+ if [ -d "$REPO_NAME" -a -d "$REPO_NAME/.git" ] ; then
echo "Using existing repo: $REPO_NAME"
else
echo "Cloning repo from GitHub to $REPO_NAME"
View
77 contrib/msysgit-install.cmd
@@ -0,0 +1,77 @@
+@echo off
+setlocal
+if not "%~1"=="" set GIT_HOME=%~f1
+if "%GIT_HOME%"=="" call :FindGitHome "git.cmd"
+
+if exist "%GIT_HOME%" goto :GitHomeOK
+
+echo MsysGit installation directory not found.>&2
+echo Try to give the directory name on the command line:>&2
+echo %0 "%ProgramFiles%\Git"
+endlocal
+exit /B 1
+
+:GitHomeOK
+set ERR=0
+
+echo Installing gitflow into "%GIT_HOME%"...
+
+call :ChkGetopt getopt.exe || set ERR=1
+if %ERR%==1 goto :End
+echo getopt.exe... Found
+
+if not exist "%GIT_HOME%\bin\git-flow" goto :Install
+echo GitFlow is already installed.>&2
+set /p mychoice="Do you want to replace it [y/n]"
+if "%mychoice%"=="y" goto :DeleteOldFiles
+goto :Abort
+
+:DeleteOldFiles
+echo Deleting old files...
+for /F %%i in ("%GIT_HOME%\git-flow*" "%GIT_HOME%\gitflow-*") do if exist "%%~fi" del /F /Q "%%~fi"
+
+:Install
+echo Copying files...
+::goto :EOF
+xcopy "%~dp0\..\git-flow" "%GIT_HOME%\bin" /Y /R /F
+if errorlevel 4 if not errorlevel 5 goto :AccessDenied
+if errorlevel 1 set ERR=1
+xcopy "%~dp0\..\git-flow*" "%GIT_HOME%\bin" /Y /R /F || set ERR=1
+xcopy "%~dp0\..\gitflow-*" "%GIT_HOME%\bin" /Y /R /F || set ERR=1
+xcopy "%~dp0\..\shFlags\src\shflags" "%GIT_HOME%\bin\gitflow-shFlags" /Y /R /F || set ERR=1
+
+if %ERR%==1 choice /T 30 /C Y /D Y /M "Some unexpected errors happened. Sorry, you'll have to fix them by yourself."
+
+:End
+endlocal & exit /B %ERR%
+goto :EOF
+
+:AccessDenied
+set ERR=1
+echo.
+echo You should run this script with "Full Administrator" rights:>&2
+echo - Right-click with Shift on the script from the Explorer>&2
+echo - Select "Run as administrator">&2
+choice /T 30 /C YN /D Y /N >nul
+goto :End
+
+:Abort
+echo Installation canceled.>&2
+set ERR=1
+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.
+exit /B 1
+
+:FindGitHome
+setlocal
+set GIT_CMD_DIR=%~dp$PATH:1
+if "%GIT_CMD_DIR%"=="" endlocal & goto :EOF
+endlocal & set GIT_HOME=%GIT_CMD_DIR:~0,-5%
+goto :EOF
View
19 git-flow
@@ -37,12 +37,17 @@
# policies, either expressed or implied, of Vincent Driessen.
#
+# set this to workaround expr problems in shFlags on freebsd
+if uname -s | egrep -iq 'bsd'; then export EXPR_COMPAT=1; fi
+
# enable debug mode
if [ "$DEBUG" = "yes" ]; then
set -x
fi
-export GITFLOW_DIR=$(dirname "$0")
+# The sed expression here replaces all backslashes by forward slashes.
+# This helps our Windows users, while not bothering our Unix users.
+export GITFLOW_DIR=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
usage() {
echo "usage: git flow <subcommand>"
@@ -75,6 +80,11 @@ main() {
# use the shFlags project to parse the command line arguments
. "$GITFLOW_DIR/gitflow-shFlags"
FLAGS_PARENT="git flow"
+
+ # allow user to request git action logging
+ DEFINE_boolean show_commands false 'show actions taken (git commands)' g
+
+ # do actual parsing
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"
@@ -94,7 +104,7 @@ main() {
# in that case, we interpret this arg as a flag for the default
# command
SUBACTION="default"
- if [ "$1" != "" ] && ! echo "$1" | grep -q "^-"; then
+ if [ "$1" != "" ] && { ! echo "$1" | grep -q "^-"; } then
SUBACTION="$1"; shift
fi
if ! type "cmd_$SUBACTION" >/dev/null 2>&1; then
@@ -104,7 +114,10 @@ main() {
fi
# run the specified action
- cmd_$SUBACTION "$@"
+ if [ $SUBACTION != "help" ] && [ $SUBCOMMAND != "init" ] ; then
+ init
+ fi
+ cmd_$SUBACTION "$@"
}
main "$@"
View
79 git-flow-feature
@@ -36,21 +36,23 @@
# 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 [-rFk] <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>]"
echo " git flow feature rebase [-i] [<name|nameprefix>]"
echo " git flow feature checkout [<name|nameprefix>]"
- echo " git flow feature pull <remote> [<name>]"
+ echo " git flow feature pull [-r] <remote> [<name>]"
}
cmd_default() {
@@ -223,7 +225,7 @@ cmd_start() {
echo ""
echo "Now, start committing on your feature. When done, use:"
echo ""
- echo " git flow feature finish $NAME"
+ echo " git flow feature finish $NAME $BASE"
echo
}
@@ -231,8 +233,11 @@ cmd_finish() {
DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
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
+ BASE=${2:-$DEVELOP_BRANCH}
+ expand_nameprefix_arg_or_current
# sanity checks
require_branch "$BRANCH"
@@ -281,43 +286,58 @@ cmd_finish() {
require_clean_working_tree
# update local repo with remote changes first, if asked
- if has "$ORIGIN/$BRANCH" "$(git_remote_branches)"; then
+ if has "$ORIGIN/$BRANCH" $(git_remote_branches); then
if flag fetch; then
git fetch -q "$ORIGIN" "$BRANCH"
+ #git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
+ git fetch -q "$ORIGIN" "$BASE"
fi
fi
- if has "$ORIGIN/$BRANCH" "$(git_remote_branches)"; then
+ if has "$ORIGIN/$BRANCH" $(git_remote_branches); then
require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH"
fi
- if has "$ORIGIN/$DEVELOP_BRANCH" "$(git_remote_branches)"; then
- require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ #if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
+ if has "$ORIGIN/$BASE" $(git_remote_branches); then
+ #require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ require_branches_equal "$BASE" "$ORIGIN/$BASE"
fi
# if the user wants to rebase, do that first
if flag rebase; then
- if ! git flow feature rebase "$NAME" "$DEVELOP_BRANCH"; then
+ #if ! git flow feature rebase "$NAME" "$DEVELOP_BRANCH"; then
+ if ! git flow feature rebase "$NAME" "$BASE"; then
warn "Finish was aborted due to conflicts during rebase."
warn "Please finish the rebase manually now."
warn "When finished, re-run:"
- warn " git flow feature finish '$NAME' '$DEVELOP_BRANCH'"
+ #warn " git flow feature finish '$NAME' '$DEVELOP_BRANCH'"
+ warn " git flow feature finish '$NAME' '$BASE'"
exit 1
fi
fi
# merge into BASE
- git checkout "$DEVELOP_BRANCH"
- if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
+ #git checkout "$DEVELOP_BRANCH"
+ git checkout "$BASE"
+ #if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
+ if [ "$(git rev-list -n2 "$BASE..$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
# oops.. we have a merge conflict!
# write the given $DEVELOP_BRANCH to a temporary file (we need it later)
mkdir -p "$DOT_GIT_DIR/.gitflow"
- echo "$DEVELOP_BRANCH" > "$DOT_GIT_DIR/.gitflow/MERGE_BASE"
+ #echo "$DEVELOP_BRANCH" > "$DOT_GIT_DIR/.gitflow/MERGE_BASE"
+ echo "$BASE" > "$DOT_GIT_DIR/.gitflow/MERGE_BASE"
echo
echo "There were merge conflicts. To resolve the merge conflict manually, use:"
echo " git mergetool"
@@ -345,19 +365,25 @@ helper_finish_cleanup() {
if noflag keep; then
- git branch -d "$BRANCH"
+ if flag force_delete; then
+ git branch -D "$BRANCH"
+ else
+ git branch -d "$BRANCH"
+ fi
fi
echo
echo "Summary of actions:"
- echo "- The feature branch '$BRANCH' was merged into '$DEVELOP_BRANCH'"
+ #echo "- The feature branch '$BRANCH' was merged into '$DEVELOP_BRANCH'"
+ echo "- The feature branch '$BRANCH' was merged into '$BASE'"
#echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported
if flag keep; then
echo "- Feature branch '$BRANCH' is still available"
else
echo "- Feature branch '$BRANCH' has been removed"
fi
- echo "- You are now on branch '$DEVELOP_BRANCH'"
+ #echo "- You are now on branch '$DEVELOP_BRANCH'"
+ echo "- You are now on branch '$BASE'"
echo
}
@@ -469,6 +495,7 @@ avoid_accidental_cross_branch_action() {
cmd_pull() {
#DEFINE_string prefix false 'alternative remote feature branch name prefix' p
+ DEFINE_boolean rebase false "pull with rebase" r
parse_remote_name "$@"
if [ -z "$REMOTE" ]; then
@@ -494,7 +521,15 @@ cmd_pull() {
# we already have a local branch called like this, so simply pull the
# remote changes in
- git pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'."
+ if flag rebase; then
+ if ! git pull --rebase -q "$REMOTE" "$BRANCH"; then
+ warn "Pull was aborted. There might be conflicts during rebase or '$REMOTE' might be inaccessible."
+ exit 1
+ fi
+ else
+ git pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'."
+ fi
+
echo "Pulled $REMOTE's changes into $BRANCH."
else
# setup the local branch clone for the first time
View
95 git-flow-hotfix
@@ -36,16 +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() {
@@ -165,14 +169,14 @@ cmd_start() {
require_branch_absent "$BRANCH"
require_tag_absent "$VERSION_PREFIX$VERSION"
if flag fetch; then
- git fetch -q "$ORIGIN" "$MASTER_BRANCH"
+ git_do fetch -q "$ORIGIN" "$MASTER_BRANCH"
fi
- if has "$ORIGIN/$MASTER_BRANCH" "$(git_remote_branches)"; then
+ if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
fi
# create branch
- git checkout -b "$BRANCH" "$BASE"
+ git_do checkout -b "$BRANCH" "$BASE"
echo
echo "Summary of actions:"
@@ -188,11 +192,59 @@ cmd_start() {
echo
}
+cmd_publish() {
+ parse_args "$@"
+ require_version_arg
+
+ # sanity checks
+ require_clean_working_tree
+ require_branch "$BRANCH"
+ git_do fetch -q "$ORIGIN"
+ require_branch_absent "$ORIGIN/$BRANCH"
+
+ # create remote branch
+ git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
+ git_do fetch -q "$ORIGIN"
+
+ # configure remote tracking
+ git config "branch.$BRANCH.remote" "$ORIGIN"
+ git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
+ git_do checkout "$BRANCH"
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new remote branch '$BRANCH' was created"
+ echo "- The local branch '$BRANCH' was configured to track the remote branch"
+ echo "- You are now on branch '$BRANCH'"
+ echo
+}
+
+cmd_track() {
+ parse_args "$@"
+ require_version_arg
+
+ # sanity checks
+ require_clean_working_tree
+ require_branch_absent "$BRANCH"
+ git_do fetch -q "$ORIGIN"
+ require_branch "$ORIGIN/$BRANCH"
+
+ # create tracking branch
+ git_do 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
@@ -208,15 +260,15 @@ cmd_finish() {
require_branch "$BRANCH"
require_clean_working_tree
if flag fetch; then
- git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
+ git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not fetch $MASTER_BRANCH from $ORIGIN."
- git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
+ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
fi
- if has "$ORIGIN/$MASTER_BRANCH" "$(git_remote_branches)"; then
+ if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
fi
- if has "$ORIGIN/$DEVELOP_BRANCH" "$(git_remote_branches)"; then
+ if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
fi
@@ -224,9 +276,9 @@ cmd_finish() {
# in case a previous attempt to finish this release branch has failed,
# but the merge into master was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
- git checkout "$MASTER_BRANCH" || \
+ git_do checkout "$MASTER_BRANCH" || \
die "Could not check out $MASTER_BRANCH."
- git merge --no-ff "$BRANCH" || \
+ git_do merge --no-ff "$BRANCH" || \
die "There were merge conflicts."
# TODO: What do we do now?
fi
@@ -241,7 +293,8 @@ cmd_finish() {
flag sign && opts="$opts -s"
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
- git tag $opts "$VERSION_PREFIX$VERSION" || \
+ [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
+ eval git_do tag $opts "$VERSION_PREFIX$VERSION" "$BRANCH" || \
die "Tagging failed. Please run finish again to retry."
fi
fi
@@ -250,28 +303,28 @@ cmd_finish() {
# in case a previous attempt to finish this release branch has failed,
# but the merge into develop was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
- git checkout "$DEVELOP_BRANCH" || \
+ git_do checkout "$DEVELOP_BRANCH" || \
die "Could not check out $DEVELOP_BRANCH."
# TODO: Actually, accounting for 'git describe' pays, so we should
# ideally git merge --no-ff $tagname here, instead!
- git merge --no-ff "$BRANCH" || \
+ git_do merge --no-ff "$BRANCH" || \
die "There were merge conflicts."
# TODO: What do we do now?
fi
# delete branch
if noflag keep; then
- git branch -d "$BRANCH"
+ git_do branch -d "$BRANCH"
fi
if flag push; then
- git push "$ORIGIN" "$DEVELOP_BRANCH" || \
+ git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not push to $DEVELOP_BRANCH from $ORIGIN."
- git push "$ORIGIN" "$MASTER_BRANCH" || \
+ git_do push "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not push to $MASTER_BRANCH from $ORIGIN."
if noflag notag; then
- git push --tags "$ORIGIN" || \
+ git_do push --tags "$ORIGIN" || \
die "Could not push tags to $ORIGIN."
fi
fi
View
23 git-flow-init
@@ -117,8 +117,14 @@ cmd_default() {
# check existence in case of an already existing repo
if [ "$should_check_existence" = "YES" ]; then
- git_local_branch_exists "$master_branch" || \
+ # if no local branch exists and a remote branch of the same
+ # name exists, checkout that branch and use it for master
+ if ! git_local_branch_exists "$master_branch" && \
+ git_remote_branch_exists "origin/$master_branch"; then
+ git branch "$master_branch" "origin/$master_branch" >/dev/null 2>&1
+ elif ! git_local_branch_exists "$master_branch"; then
die "Local branch '$master_branch' does not exist."
+ fi
fi
# store the name of the master branch
@@ -147,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] "
@@ -200,7 +212,11 @@ cmd_default() {
# default production branch and develop was "created". We should create
# the develop branch now in that case (we base it on master, of course)
if ! git_local_branch_exists "$develop_branch"; then
- git branch --no-track "$develop_branch" "$master_branch"
+ if git_remote_branch_exists "origin/$develop_branch"; then
+ git branch "$develop_branch" "origin/$develop_branch" >/dev/null 2>&1
+ else
+ git branch --no-track "$develop_branch" "$master_branch"
+ fi
created_gitflow_branch=1
fi
@@ -218,6 +234,7 @@ cmd_default() {
! git config --get gitflow.prefix.release >/dev/null 2>&1 ||
! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 ||
! git config --get gitflow.prefix.support >/dev/null 2>&1 ||
+ ! git config --get gitflow.prefix.project >/dev/null 2>&1 ||
! git config --get gitflow.prefix.versiontag >/dev/null 2>&1; then
echo
echo "How to name your supporting branch prefixes?"
View
530 git-flow-project
@@ -0,0 +1,530 @@
+#
+# git-flow -- A collection of Git extensions to provide high-level
+# repository operations for Vincent Driessen's branching model.
+#
+# Original blog post presenting this model is found at:
+# http://nvie.com/git-model
+#
+# Feel free to contribute to this project at:
+# http://github.com/nvie/gitflow
+#
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
+#
+
+init() {
+ require_git_repo
+ require_gitflow_initialized
+ gitflow_load_settings
+ PREFIX=$(git config --get gitflow.prefix.project)
+}
+
+usage() {
+ echo "usage: git flow project [list] [-v]"
+ echo " git flow project start [-F] <name> [<base>]"
+ echo " git flow project finish [-rFkDS] [<name|nameprefix>]"
+ echo " git flow project publish <name>"
+ echo " git flow project track <name>"
+ echo " git flow project diff [<name|nameprefix>]"
+ echo " git flow project rebase [-i] [<name|nameprefix>]"
+ echo " git flow project checkout [<name|nameprefix>]"
+ echo " git flow project pull [-r] <remote> [<name>]"
+}
+
+cmd_default() {
+ cmd_list "$@"
+}
+
+cmd_list() {
+ DEFINE_boolean verbose false 'verbose (more) output' v
+ parse_args "$@"
+
+ local project_branches
+ local current_branch
+ local short_names
+ project_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX")
+ if [ -z "$project_branches" ]; then
+ warn "No project branches exist."
+ warn ""
+ warn "You can start a new project branch:"
+ warn ""
+ warn " git flow project start <name> [<base>]"
+ warn ""
+ exit 0
+ fi
+ current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
+ short_names=$(echo "$project_branches" | sed "s ^$PREFIX g")
+
+ # determine column width first
+ local width=0
+ local branch
+ for branch in $short_names; do
+ local len=${#branch}
+ width=$(max $width $len)
+ done
+ width=$(($width+3))
+
+ local branch
+ for branch in $short_names; do
+ local fullname=$PREFIX$branch
+ local base=$(git merge-base "$fullname" "$DEVELOP_BRANCH")
+ local develop_sha=$(git rev-parse "$DEVELOP_BRANCH")
+ local branch_sha=$(git rev-parse "$fullname")
+ if [ "$fullname" = "$current_branch" ]; then
+ printf "* "
+ else
+ printf " "
+ fi
+ if flag verbose; then
+ printf "%-${width}s" "$branch"
+ if [ "$branch_sha" = "$develop_sha" ]; then
+ printf "(no commits yet)"
+ elif [ "$base" = "$branch_sha" ]; then
+ printf "(is behind develop, may ff)"
+ elif [ "$base" = "$develop_sha" ]; then
+ printf "(based on latest develop)"
+ else
+ printf "(may be rebased)"
+ fi
+ else
+ printf "%s" "$branch"
+ fi
+ echo
+ done
+}
+
+cmd_help() {
+ usage
+ exit 0
+}
+
+require_name_arg() {
+ if [ "$NAME" = "" ]; then
+ warn "Missing argument <name>"
+ usage
+ exit 1
+ fi
+}
+
+expand_nameprefix_arg() {
+ require_name_arg
+
+ local expanded_name
+ local exitcode
+ expanded_name=$(gitflow_resolve_nameprefix "$NAME" "$PREFIX")
+ exitcode=$?
+ case $exitcode in
+ 0) NAME=$expanded_name
+ BRANCH=$PREFIX$NAME
+ ;;
+ *) exit 1 ;;
+ esac
+}
+
+use_current_project_branch_name() {
+ local current_branch=$(git_current_branch)
+ if startswith "$current_branch" "$PREFIX"; then
+ BRANCH=$current_branch
+ NAME=${BRANCH#$PREFIX}
+ else
+ warn "The current HEAD is no project branch."
+ warn "Please specify a <name> argument."
+ exit 1
+ fi
+}
+
+expand_nameprefix_arg_or_current() {
+ if [ "$NAME" != "" ]; then
+ expand_nameprefix_arg
+ require_branch "$PREFIX$NAME"
+ else
+ use_current_project_branch_name
+ fi
+}
+
+name_or_current() {
+ if [ -z "$NAME" ]; then
+ use_current_project_branch_name
+ fi
+}
+
+parse_args() {
+ # parse options
+ FLAGS "$@" || exit $?
+ eval set -- "${FLAGS_ARGV}"
+
+ # read arguments into global variables
+ NAME=$1
+ BRANCH=$PREFIX$NAME
+}
+
+parse_remote_name() {
+ # parse options
+ FLAGS "$@" || exit $?
+ eval set -- "${FLAGS_ARGV}"
+
+ # read arguments into global variables
+ REMOTE=$1
+ NAME=$2
+ BRANCH=$PREFIX$NAME
+}
+
+cmd_start() {
+ DEFINE_boolean fetch false 'fetch from origin before performing local operation' F
+ parse_args "$@"
+ BASE=${2:-$DEVELOP_BRANCH}
+ require_name_arg
+
+ # sanity checks
+ require_branch_absent "$BRANCH"
+
+ # update the local repo with remote changes, if asked
+ if flag fetch; then
+ git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
+ fi
+
+ # if the origin branch counterpart exists, assert that the local branch
+ # isn't behind it (to avoid unnecessary rebasing)
+ if git_branch_exists "$ORIGIN/$DEVELOP_BRANCH"; then
+ require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ fi
+
+ # create branch
+ if ! git checkout -b "$BRANCH" "$BASE"; then
+ die "Could not create project branch '$BRANCH'"
+ fi
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new branch '$BRANCH' was created, based on '$BASE'"
+ echo "- You are now on branch '$BRANCH'"
+ echo ""
+ echo "Now, use this project branch as a base for creating feature branches. When the project is done, use:"
+ echo ""
+ echo " git flow project finish $NAME"
+ echo
+}
+
+cmd_finish() {
+ DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
+ 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 project branch after finish" D
+ DEFINE_boolean squash false "squash project during merge" S
+ parse_args "$@"
+ expand_nameprefix_arg_or_current
+
+ # sanity checks
+ require_branch "$BRANCH"
+
+ # detect if we're restoring from a merge conflict
+ if [ -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" ]; then
+ #
+ # TODO: detect that we're working on the correct branch here!
+ # The user need not necessarily have given the same $NAME twice here
+ # (although he/she should).
+ #
+
+ # TODO: git_is_clean_working_tree() should provide an alternative
+ # exit code for "unmerged changes in working tree", which we should
+ # actually be testing for here
+ if git_is_clean_working_tree; then
+ FINISH_BASE=$(cat "$DOT_GIT_DIR/.gitflow/MERGE_BASE")
+
+ # Since the working tree is now clean, either the user did a
+ # succesfull merge manually, or the merge was cancelled.
+ # We detect this using git_is_branch_merged_into()
+ if git_is_branch_merged_into "$BRANCH" "$FINISH_BASE"; then
+ rm -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE"
+ helper_finish_cleanup
+ exit 0
+ else
+ # If the user cancelled the merge and decided to wait until later,
+ # that's fine. But we have to acknowledge this by removing the
+ # MERGE_BASE file and continuing normal execution of the finish
+ rm -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE"
+ fi
+ else
+ echo
+ echo "Merge conflicts not resolved yet, use:"
+ echo " git mergetool"
+ echo " git commit"
+ echo
+ echo "You can then complete the finish by running it again:"
+ echo " git flow project finish $NAME"
+ echo
+ exit 1
+ fi
+ fi
+
+ # sanity checks
+ require_clean_working_tree
+
+ # update local repo with remote changes first, if asked
+ if has "$ORIGIN/$BRANCH" $(git_remote_branches); then
+ if flag fetch; then
+ git fetch -q "$ORIGIN" "$BRANCH"
+ git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
+ fi
+ fi
+
+ if has "$ORIGIN/$BRANCH" $(git_remote_branches); then
+ require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH"
+ fi
+ if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
+ require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ fi
+
+ # if the user wants to rebase, do that first
+ if flag rebase; then
+ if ! git flow project rebase "$NAME" "$DEVELOP_BRANCH"; then
+ warn "Finish was aborted due to conflicts during rebase."
+ warn "Please finish the rebase manually now."
+ warn "When finished, re-run:"
+ warn " git flow project finish '$NAME' '$DEVELOP_BRANCH'"
+ exit 1
+ fi
+ fi
+
+ # merge into BASE
+ git checkout "$DEVELOP_BRANCH"
+ if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
+ git merge --ff "$BRANCH"
+ else
+ 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
+ # oops.. we have a merge conflict!
+ # write the given $DEVELOP_BRANCH to a temporary file (we need it later)
+ mkdir -p "$DOT_GIT_DIR/.gitflow"
+ echo "$DEVELOP_BRANCH" > "$DOT_GIT_DIR/.gitflow/MERGE_BASE"
+ echo
+ echo "There were merge conflicts. To resolve the merge conflict manually, use:"
+ echo " git mergetool"
+ echo " git commit"
+ echo
+ echo "You can then complete the finish by running it again:"
+ echo " git flow project finish $NAME"
+ echo
+ exit 1
+ fi
+
+ # when no merge conflict is detected, just clean up the project branch
+ helper_finish_cleanup
+}
+
+helper_finish_cleanup() {
+ # sanity checks
+ require_branch "$BRANCH"
+ require_clean_working_tree
+
+ # delete branch
+ if flag fetch; then
+ git push "$ORIGIN" ":refs/heads/$BRANCH"
+ fi
+
+
+ if noflag keep; then
+ if flag force_delete; then
+ git branch -D "$BRANCH"
+ else
+ git branch -d "$BRANCH"
+ fi
+ fi
+
+ echo
+ echo "Summary of actions:"
+ echo "- The project branch '$BRANCH' was merged into '$DEVELOP_BRANCH'"
+ #echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported
+ if flag keep; then
+ echo "- Project branch '$BRANCH' is still available"
+ else
+ echo "- Project branch '$BRANCH' has been removed"
+ fi
+ echo "- You are now on branch '$DEVELOP_BRANCH'"
+ echo
+}
+
+cmd_publish() {
+ parse_args "$@"
+ expand_nameprefix_arg
+
+ # sanity checks
+ require_clean_working_tree
+ require_branch "$BRANCH"
+ git fetch -q "$ORIGIN"
+ require_branch_absent "$ORIGIN/$BRANCH"
+
+ # create remote branch
+ git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
+ git fetch -q "$ORIGIN"
+
+ # configure remote tracking
+ git config "branch.$BRANCH.remote" "$ORIGIN"
+ git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
+ git checkout "$BRANCH"
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new remote branch '$BRANCH' was created"
+ echo "- The local branch '$BRANCH' was configured to track the remote branch"
+ echo "- You are now on branch '$BRANCH'"
+ echo
+}
+
+cmd_track() {
+ parse_args "$@"
+ require_name_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_diff() {
+ parse_args "$@"
+
+ if [ "$NAME" != "" ]; then
+ expand_nameprefix_arg
+ BASE=$(git merge-base "$DEVELOP_BRANCH" "$BRANCH")
+ git diff "$BASE..$BRANCH"
+ else
+ if ! git_current_branch | grep -q "^$PREFIX"; then
+ die "Not on a project branch. Name one explicitly."
+ fi
+
+ BASE=$(git merge-base "$DEVELOP_BRANCH" HEAD)
+ git diff "$BASE"
+ fi
+}
+
+cmd_checkout() {
+ parse_args "$@"
+
+ if [ "$NAME" != "" ]; then
+ expand_nameprefix_arg
+ git checkout "$BRANCH"
+ else
+ die "Name a project branch explicitly."
+ fi
+}
+
+cmd_co() {
+ # Alias for checkout
+ cmd_checkout "$@"
+}
+
+cmd_rebase() {
+ DEFINE_boolean interactive false 'do an interactive rebase' i
+ parse_args "$@"
+ expand_nameprefix_arg_or_current
+ warn "Will try to rebase '$NAME'..."
+ require_clean_working_tree
+ require_branch "$BRANCH"
+
+ git checkout -q "$BRANCH"
+ local OPTS=
+ if flag interactive; then
+ OPTS="$OPTS -i"
+ fi
+ git rebase $OPTS "$DEVELOP_BRANCH"
+}
+
+avoid_accidental_cross_branch_action() {
+ local current_branch=$(git_current_branch)
+ if [ "$BRANCH" != "$current_branch" ]; then
+ warn "Trying to pull from '$BRANCH' while currently on branch '$current_branch'."
+ warn "To avoid unintended merges, git-flow aborted."
+ return 1
+ fi
+ return 0
+}
+
+cmd_pull() {
+ #DEFINE_string prefix false 'alternative remote project branch name prefix' p
+ DEFINE_boolean rebase false "pull with rebase" r
+ parse_remote_name "$@"
+
+ if [ -z "$REMOTE" ]; then
+ die "Name a remote explicitly."
+ fi
+ name_or_current
+
+ # To avoid accidentally merging different project branches into each other,
+ # die if the current porject branch differs from the requested $NAME
+ # argument.
+ local current_branch=$(git_current_branch)
+ if startswith "$current_branch" "$PREFIX"; then
+ # we are on a local project branch already, so $BRANCH must be equal to
+ # the current branch
+ avoid_accidental_cross_branch_action || die
+ fi
+
+ require_clean_working_tree
+
+ if git_branch_exists "$BRANCH"; then
+ # Again, avoid accidental merges
+ avoid_accidental_cross_branch_action || die
+
+ # we already have a local branch called like this, so simply pull the
+ # remote changes in
+ if flag rebase; then
+ if ! git pull --rebase -q "$REMOTE" "$BRANCH"; then
+ warn "Pull was aborted. There might be conflicts during rebase or '$REMOTE' might be inaccessible."
+ exit 1
+ fi
+ else
+ git pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'."
+ fi
+
+ echo "Pulled $REMOTE's changes into $BRANCH."
+ else
+ # setup the local branch clone for the first time
+ git fetch -q "$REMOTE" "$BRANCH" || die "Fetch failed." # stores in FETCH_HEAD
+ git branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed."
+ git checkout -q "$BRANCH" || die "Checking out new local branch failed."
+ echo "Created local branch $BRANCH based on $REMOTE's $BRANCH."
+ fi
+}
View
94 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>"
- echo " git flow release finish [-Fsumpk] <version>"
+ echo " git flow release start [-F] <version> [<base>]"
+ echo " git flow release finish [-FsumpkS] <version>"
echo " git flow release publish <name>"
echo " git flow release track <name>"
}
@@ -134,7 +136,7 @@ require_version_arg() {
}
require_base_is_on_develop() {
- if ! git branch --no-color --contains "$BASE" 2>/dev/null \
+ if ! git_do branch --no-color --contains "$BASE" 2>/dev/null \
| sed 's/[* ] //g' \
| grep -q "^$DEVELOP_BRANCH\$"; then
die "fatal: Given base '$BASE' is not a valid commit on '$DEVELOP_BRANCH'."
@@ -162,14 +164,14 @@ cmd_start() {
require_branch_absent "$BRANCH"
require_tag_absent "$VERSION_PREFIX$VERSION"
if flag fetch; then
- git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
+ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
fi
- if has "$ORIGIN/$DEVELOP_BRANCH" "$(git_remote_branches)"; then
+ if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
fi
# create branch
- git checkout -b "$BRANCH" "$BASE"
+ git_do checkout -b "$BRANCH" "$BASE"
echo
echo "Summary of actions:"
@@ -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
@@ -206,15 +210,15 @@ cmd_finish() {
require_branch "$BRANCH"
require_clean_working_tree
if flag fetch; then
- git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
+ git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not fetch $MASTER_BRANCH from $ORIGIN."
- git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
+ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
fi
- if has "$ORIGIN/$MASTER_BRANCH" "$(git_remote_branches)"; then
+ if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
fi
- if has "$ORIGIN/$DEVELOP_BRANCH" "$(git_remote_branches)"; then
+ if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
fi
@@ -222,11 +226,17 @@ cmd_finish() {
# in case a previous attempt to finish this release branch has failed,
# but the merge into master was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
- git checkout "$MASTER_BRANCH" || \
+ git_do 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_do merge --no-ff "$BRANCH" || \
+ die "There were merge conflicts."
+ # TODO: What do we do now?
+ else
+ git_do merge --squash "$BRANCH" || \
+ die "There were merge conflicts."
+ git_do commit
+ fi
fi
if noflag notag; then
@@ -239,7 +249,8 @@ cmd_finish() {
flag sign && opts="$opts -s"
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
- git tag $opts "$tagname" || \
+ [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
+ eval git_do tag $opts "$tagname" "$BRANCH" || \
die "Tagging failed. Please run finish again to retry."
fi
fi
@@ -248,34 +259,41 @@ cmd_finish() {
# in case a previous attempt to finish this release branch has failed,
# but the merge into develop was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
- git checkout "$DEVELOP_BRANCH" || \
+ git_do checkout "$DEVELOP_BRANCH" || \
die "Could not check out $DEVELOP_BRANCH."
# 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_do merge --no-ff "$BRANCH" || \
+ die "There were merge conflicts."
+ # TODO: What do we do now?
+ else
+ git_do merge --squash "$BRANCH" || \
+ die "There were merge conflicts."
+ # TODO: What do we do now?
+ git_do commit
+ fi
fi
# delete branch
if noflag keep; then
if [ "$BRANCH" = "$(git_current_branch)" ]; then
- git checkout "$MASTER_BRANCH"
+ git_do checkout "$MASTER_BRANCH"
fi
- git branch -d "$BRANCH"
+ git_do branch -d "$BRANCH"
fi
if flag push; then
- git push "$ORIGIN" "$DEVELOP_BRANCH" || \
+ git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not push to $DEVELOP_BRANCH from $ORIGIN."
- git push "$ORIGIN" "$MASTER_BRANCH" || \
+ git_do push "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not push to $MASTER_BRANCH from $ORIGIN."
if noflag notag; then
- git push --tags "$ORIGIN" || \
+ git_do push --tags "$ORIGIN" || \
die "Could not push tags to $ORIGIN."
fi
- git push "$ORIGIN" :"$BRANCH" || \
+ git_do push "$ORIGIN" :"$BRANCH" || \
die "Could not delete the remote $BRANCH in $ORIGIN."
fi
@@ -306,17 +324,17 @@ cmd_publish() {
# sanity checks
require_clean_working_tree
require_branch "$BRANCH"
- git fetch -q "$ORIGIN"
+ git_do fetch -q "$ORIGIN"
require_branch_absent "$ORIGIN/$BRANCH"
# create remote branch
- git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
- git fetch -q "$ORIGIN"
+ git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
+ git_do fetch -q "$ORIGIN"
# configure remote tracking
- git config "branch.$BRANCH.remote" "$ORIGIN"
- git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
- git checkout "$BRANCH"
+ git_do config "branch.$BRANCH.remote" "$ORIGIN"
+ git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
+ git_do checkout "$BRANCH"
echo
echo "Summary of actions:"
@@ -333,11 +351,11 @@ cmd_track() {
# sanity checks
require_clean_working_tree
require_branch_absent "$BRANCH"
- git fetch -q "$ORIGIN"
+ git_do fetch -q "$ORIGIN"
require_branch "$ORIGIN/$BRANCH"
# create tracking branch
- git checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
+ git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
echo
echo "Summary of actions:"
View
16 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."
@@ -167,12 +169,12 @@ cmd_start() {
# fetch remote changes
if flag fetch; then
- git fetch -q "$ORIGIN" "$BASE"
+ git_do fetch -q "$ORIGIN" "$BASE"
fi
require_branch_absent "$BRANCH"
# create branch
- git checkout -b "$BRANCH" "$BASE"
+ git_do checkout -b "$BRANCH" "$BASE"
echo
echo "Summary of actions:"
View
2  git-flow-version
@@ -36,7 +36,7 @@
# policies, either expressed or implied, of Vincent Driessen.
#
-GITFLOW_VERSION=0.4.1
+GITFLOW_VERSION=0.4.2-pre
usage() {
echo "usage: git flow version"
View
24 gitflow-common
@@ -45,7 +45,7 @@ warn() { echo "$@" >&2; }
die() { warn "$@"; exit 1; }
escape() {
- echo "$1" | sed 's/\([\.\+\$\*]\)/\\\1/g'
+ echo "$1" | sed 's/\([\.\$\*]\)/\\\1/g'
}
# set logic
@@ -70,6 +70,14 @@ noflag() { local FLAG; eval FLAG='$FLAGS_'$1; [ $FLAG -ne $FLAGS_TRUE ]; }
# Git specific common functionality
#
+git_do() {
+ # equivalent to git, used to indicate actions that make modifications
+ if flag show_commands; then
+ echo "git $@" >&2
+ fi
+ git "$@"
+}
+
git_local_branches() { git branch --no-color | sed 's/^[* ] //'; }
git_remote_branches() { git branch -r --no-color | sed 's/^[* ] //'; }
git_all_branches() { ( git branch --no-color; git branch -r --no-color) | sed 's/^[* ] //'; }
@@ -97,6 +105,10 @@ git_local_branch_exists() {
has $1 $(git_local_branches)
}
+git_remote_branch_exists() {
+ has $1 $(git_remote_branches)
+}
+
git_branch_exists() {
has $1 $(git_all_branches)
}
@@ -181,7 +193,7 @@ gitflow_is_initialized() {
# loading settings that can be overridden using git config
gitflow_load_settings() {
- export DOT_GIT_DIR=$(git rev-parse --git-dir >/dev/null 2>&1)
+ export DOT_GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
export MASTER_BRANCH=$(git config --get gitflow.branch.master)
export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop)
export ORIGIN=$(git config --get gitflow.origin || echo origin)
@@ -288,9 +300,11 @@ require_branch_absent() {
}
require_tag_absent() {
- if has $1 $(git_all_tags); then
- die "Tag '$1' already exists. Pick another name."
- fi
+ for tag in $(git_all_tags); do
+ if [ "$1" = "$tag" ]; then
+ die "Tag '$1' already exists. Pick another name."
+ fi
+ done
}
require_branches_equal() {
Please sign in to comment.
Something went wrong with that request. Please try again.