Skip to content

Commit

Permalink
Release/2.2.0 (#74)
Browse files Browse the repository at this point in the history
* feat(git-flow): add support for busybox(#12)

* feat(init): add support for environment credentials (#19)

Allows git flow to fall back to the same environment variables git uses
for setting the author and committer details if they are not present in
the users .gitconfig

* feat(init): add option to sign initial commit (#59)

When running git flow init the following option is now available when
creating a git repository using git flow..

1) -g, --[no]sign	Sign initial commit when creating a repository

When setting up git flow in a freshly created git repository with no
prior commits or when using git flow to create a git repository in an
existing folder the sign flag will create a signed empty commit with the
message initial commit.

* feat(feature): add feature release command (#64)

Added git flow feature release to provide a quick way to create a
release branch from a existing feature branch.

* fix(hotfix): git flow hotfix track fails due to branch name check (#68)
* feat(hotfix): add cherrypick option to hotfix finish (#73)
* feat(hotfix): add  backmerge option to release branch (#71)
* fix(hotfix): git flow hotfix finish -b back-merges to develop (#66)

When runing hotfix finish the following options have been the following
options have been added:

1) -r, --releaseBackmerge	Back-merge to release branch if exists
2) -c, --cherrypick		Cherry Pick to develop instead of merge
3) -b, --[no]nobackmerge	Don't merge master, or tag onto develop

NOTE: One one of the above three options can be used at any given time
since it doesn't make sence to combine them.

* fix(log): fix git flow log help message (#15)

git flow log help no longer implies it can only be used with feature
branches

* chore(release): release version 2.2.0

---------

Signed-off-by: Shea690901 <[email protected]>
Co-authored-by: Filipe Kiss <[email protected]>
Co-authored-by: Shea690901 <[email protected]>
Co-authored-by: Dmitry Bogatov <git#[email protected]>
Co-authored-by: ab <[email protected]>
Co-authored-by: Adam Rodger <[email protected]>
Co-authored-by: Bankers, R.H.M. (Rob) <[email protected]>
Co-authored-by: blooper05 <[email protected]>
Co-authored-by: simonweil  <[email protected]>
  • Loading branch information
9 people authored Jul 6, 2023
1 parent d752862 commit 56cd71a
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 68 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# Changelog

#### 2.2.0
* feat(init): add option to sign initial commit (#59)
* feat(git-flow): add support for environment credentials (#19)
* feat(git-flow): add support for busybox(#12)
* feat(feature): add feature release command (#64)
* feat(hotfix): add cherrypick option to hotfix finish (#73)
* feat(hotfix): add backmerge option to release branch (#71)
* fix(hotfix): git flow hotfix finish -b still back-merges to develop (#66)
* fix(hotfix): git flow hotfix track fails due to branch name check (#68)
* fix: git flow log help message (#15)

#### 2.1.0
* feat: add create command to release allowing for a single step release prodution
* feat: add missing hook script filter-flow-release-finish-version
* fix: multi-line tag message when using -m
* docs: update readme with better description as to why this fork was created. Thank You [shaedrick](https://github.com/shaedrich)
**NOTE:** The format for a multi-line tag message is now "$(printf 'line of text with \n escape codes placed as needed for proper formating of the message')"


#### 2.0.1
* fix incorrect version identification along with updating source repository in gitflow-installer. Corrections pointed out by [bobstuart](https://github.com/bobstuart)

Expand Down
5 changes: 3 additions & 2 deletions git-flow
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
# http://blog.avirtualhome.com/development-workflow-using-git/
#
# Feel free to contribute to this project at:
# http://github.com/petervanderdoes/gitflow
# http://github.com/CJ-Systems/gitflow-cjs
#
# Authors:
# Copyright 2003 CJ Systems. All rights reserved.
# Copyright 2012-2019 Peter van der Does. All rights reserved.
#
# Original Author:
Expand Down Expand Up @@ -46,7 +47,7 @@ fi
# git-flow file is a symbolic link
case $(uname -s) in
Linux)
export GITFLOW_DIR=$(dirname "$(readlink -e "$0")")
export GITFLOW_DIR=$(dirname "$(readlink -f "$0")")
;;
FreeBSD|OpenBSD|NetBSD)
export FLAGS_GETOPT_CMD='/usr/local/bin/getopt'
Expand Down
3 changes: 2 additions & 1 deletion git-flow-bugfix
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# http://blog.avirtualhome.com/development-workflow-using-git/
#
# Feel free to contribute to this project at:
# http://github.com/petervanderdoes/gitflow
# http://github.com/CJ-Systems/gitflow-cjs
#
# Authors:
# Copyright 2003 CJ Systems. All rights reserved.
# Copyright 2012-2019 Peter van der Does. All rights reserved.
#
# Original Author:
Expand Down
3 changes: 2 additions & 1 deletion git-flow-config
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# http://blog.avirtualhome.com/development-workflow-using-git/
#
# Feel free to contribute to this project at:
# http://github.com/petervanderdoes/gitflow
# http://github.com/CJ-Systems/gitflow-cjs
#
# Authors:
# Copyright 2003 CJ Systems. All rights reserved.
# Copyright 2012-2019 Peter van der Does. All rights reserved.
#
#
Expand Down
34 changes: 33 additions & 1 deletion git-flow-feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# http://blog.avirtualhome.com/development-workflow-using-git/
#
# Feel free to contribute to this project at:
# http://github.com/petervanderdoes/gitflow
# http://github.com/CJ-Systems/gitflow-cjs
#
# Authors:
# Copyright 2003 CJ Systems. All rights reserved.
# Copyright 2012-2019 Peter van der Does. All rights reserved.
#
# Original Author:
Expand Down Expand Up @@ -58,6 +59,7 @@ git flow feature checkout
git flow feature pull
git flow feature delete
git flow feature rename
git flow feature release
Manage your feature branches.
Expand Down Expand Up @@ -429,6 +431,36 @@ no-ff! Never fast-forward during the merge
helper_finish_cleanup
}

cmd_release() {
OPTIONS_SPEC="\
git flow feature release [-h]
Create a release based on current feature
--
h,help! Show this help
"

# 1) pull dev from origin
# git_do checkout "$BRANCH"
# git_do (or somth exists alredy here?)

# Parse arguments
parse_args "$@"

# Use current branch if no name is given
if [ "$NAME" = "" ]; then
gitflow_use_current_branch_name
fi

# 2) Update feature with dev
echo "Rebasing $BASE_BRANCH to $BRANCH"
git_do flow feature rebase || die "Could not rebase $BRANCH which is based on $BASE_BRANCH"

# 3) create release
git_do flow release start $NAME $BRANCH

}

helper_finish_cleanup() {
local keepmsg remotebranchdeleted localbranchdeleted

Expand Down
177 changes: 130 additions & 47 deletions git-flow-hotfix
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# http://blog.avirtualhome.com/development-workflow-using-git/
#
# Feel free to contribute to this project at:
# http://github.com/petervanderdoes/gitflow
# http://github.com/CJ-Systems/gitflow-cjs
#
# Authors:
# Copyright 2003 CJ Systems. All rights reserved.
# Copyright 2012-2019 Peter van der Does. All rights reserved.
#
# Original Author:
Expand Down Expand Up @@ -348,23 +349,24 @@ showcommands! Show git commands while executing them

# Sanity checks
require_clean_working_tree
require_branch_absent "$BRANCH"
git_do fetch -q "$ORIGIN"
require_branch "$ORIGIN/$BRANCH"
require_local_branch_absent "$BRANCH"

git_do fetch -q "$ORIGIN" || die "Could not fetch branch '$BRANCH' from remote '$ORIGIN'."
git_remote_branch_exists "$ORIGIN/$BRANCH"

# Create tracking branch
git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH" || die "Could not create branch '$BRANCH'."

echo
echo "Summary of actions:"
echo "- A new remote tracking branch '$BRANCH' was created"
echo "- You are now on branch '$BRANCH'"
echo "- You are now on branch '$(git_current_branch)'"
echo
}

cmd_finish() {
OPTIONS_SPEC="\
git flow hotfix finish [-h] [-F] [-s] [-u] [-m | -f ] [-p] [-k] [-n] [-b] [-S] <version>
git flow hotfix finish [-h] [-F] [-s] [-u] [-m | -f ] [-p] [-k] [-n] [-b | -c | -r] [-S] <version>
Finish hotfix branch <version>
--
Expand All @@ -382,8 +384,10 @@ k,[no]keep Keep branch after performing finish
D,[no]force_delete Force delete hotfix branch after finish
n,[no]notag Don't tag this hotfix
b,[no]nobackmerge Don't back-merge master, or tag if applicable, in develop
r,releaseBackmerge Back-merge to release branch if exists
S,[no]squash Squash hotfix during merge
T,tagname! Use given tag name
c,cherrypick Cherry Pick to $DEVELOP_BRANCH instead of merge
"
local opts commit keepmsg remotebranchdeleted localbranchdeleted

Expand All @@ -400,25 +404,29 @@ T,tagname! Use given tag name
DEFINE_boolean 'force_delete' false "force delete hotfix branch after finish" D
DEFINE_boolean 'notag' false "don't tag this hotfix" n
DEFINE_boolean 'nobackmerge' false "don't back-merge $MASTER_BRANCH, or tag if applicable, in $DEVELOP_BRANCH " b
DEFINE_boolean 'releasebackmerge' false "back-merge to release branch if exists" r
DEFINE_boolean 'squash' false "squash release during merge" S
DEFINE_boolean 'squash-info' false "add branch info during squash"
DEFINE_string 'tagname' "" "use the given tag name" T
DEFINE_boolean 'cherrypick' false "Cherry Pick to $DEVELOP_BRANCH instead of merge" c

# Override defaults with values from config
gitflow_override_flag_boolean "hotfix.finish.fetch" "fetch"
gitflow_override_flag_boolean "hotfix.finish.sign" "sign"
gitflow_override_flag_boolean "hotfix.finish.push" "push"
gitflow_override_flag_boolean "hotfix.finish.keep" "keep"
gitflow_override_flag_boolean "hotfix.finish.keepremote" "keepremote"
gitflow_override_flag_boolean "hotfix.finish.keeplocal" "keeplocal"
gitflow_override_flag_boolean "hotfix.finish.force-delete" "force_delete"
gitflow_override_flag_boolean "hotfix.finish.notag" "notag"
gitflow_override_flag_boolean "hotfix.finish.nobackmerge" "nobackmerge"
gitflow_override_flag_boolean "hotfix.finish.squash" "squash"
gitflow_override_flag_boolean "hotfix.finish.squash-info" "squash_info"
gitflow_override_flag_string "hotfix.finish.signingkey" "signingkey"
gitflow_override_flag_string "hotfix.finish.message" "message"
gitflow_override_flag_string "hotfix.finish.messagefile" "messagefile"
gitflow_override_flag_boolean "hotfix.finish.fetch" "fetch"
gitflow_override_flag_boolean "hotfix.finish.sign" "sign"
gitflow_override_flag_boolean "hotfix.finish.push" "push"
gitflow_override_flag_boolean "hotfix.finish.keep" "keep"
gitflow_override_flag_boolean "hotfix.finish.keepremote" "keepremote"
gitflow_override_flag_boolean "hotfix.finish.keeplocal" "keeplocal"
gitflow_override_flag_boolean "hotfix.finish.force-delete" "force_delete"
gitflow_override_flag_boolean "hotfix.finish.notag" "notag"
gitflow_override_flag_boolean "hotfix.finish.nobackmerge" "nobackmerge"
gitflow_override_flag_boolean "hotfix.finish.releasebackmerge" "releasebackmerge"
gitflow_override_flag_boolean "hotfix.finish.squash" "squash"
gitflow_override_flag_boolean "hotfix.finish.squash-info" "squash_info"
gitflow_override_flag_string "hotfix.finish.signingkey" "signingkey"
gitflow_override_flag_string "hotfix.finish.message" "message"
gitflow_override_flag_string "hotfix.finish.messagefile" "messagefile"
gitflow_override_flag_boolean "hotfix.finish.cherrypick" "cherrypick"

# Parse arguments
parse_args "$@"
Expand Down Expand Up @@ -448,6 +456,19 @@ T,tagname! Use given tag name
FLAGS_keep=$FLAGS_TRUE
fi

# Check that not both no merge flags were given
if flag cherrypick && flag nobackmerge; then
die "You can't use 'cherrypick' and 'nobackmerge' together."
fi

if flag cherrypick && flag releasebackmerge; then
die "You can't use 'cherrypick' and 'releasebackmerge' together."
fi

if flag nobackmerge && flag releasebackmerge; then
die "You can't use 'nobackmerge' && 'releasebackmerge' together."
fi

# Sanity checks
require_branch "$BRANCH"
require_clean_working_tree
Expand Down Expand Up @@ -516,6 +537,42 @@ T,tagname! Use given tag name

run_pre_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH"

if flag cherrypick; then
printf 'this is the cherrypick\n'
read
git_do checkout "$DEVELOP_BRANCH" || die "Could not check out branch '$DEVELOP_BRANCH'."

local old_IFS=$IFS # save the field separator
IFS=$'\n' # new field separator, the end of line
for git_line in $(git log --format="%H %s" --reverse $MASTER_BRANCH..$BRANCH | grep -vE "^[a-z0-9]* Merge branch '[^'].*?'$"); do
local commit_hash=$(echo $git_line | cut -d" " -f1)
if [[ $(git log $DEVELOP_BRANCH --grep "$commit_hash" | wc -l) -eq 0 ]]; then
echo "\n${LIGHTGREEN}Cherry picking: $git_line${NOCOLOR}"
git_do cherry-pick -x -s $commit_hash
if [[ $? -ne 0 ]]; then
echo "
===============================================================
= Cherry pick has conflicts, steps to continue:
= 1. Fix the conflicts
= 2. Stage the fixed file: '${BLUE}git add <file names>${NOCOLOR}'
= 3. Continue the cherry pick: '${BLUE}git cherry-pick --continue${NOCOLOR}'
= *** If fixing the conflict results in an empty commit,
= you will need to run this command: '${BLUE}git commit --allow-empty${NOCOLOR}'
= 4. Switch back to the hotfix branch: '${BLUE}git checkout $BRANCH${NOCOLOR}'
= 5. Rerun the finish command: '${BLUE}git flow hotfix finish${NOCOLOR}'
= OR run '${BLUE}git cherry-pick --abort${NOCOLOR}' to abort the cherry pick
===============================================================\n"
die "Cherry pick failed for commit: $commit_hash"
fi
else
echo "\n${LIGHTGREEN}Commit has already been Cherry Picked: $git_line${NOCOLOR}"
fi
done
IFS=$old_IFS # restore default field separator

git_do checkout $BRANCH || die "Could not check out branch '$BRANCH'."
fi

# Try to merge into BASE.
# In case a previous attempt to finish this release branch has failed,
# but the merge into BASE was successful, we skip it now
Expand Down Expand Up @@ -551,44 +608,66 @@ T,tagname! Use given tag name
fi
fi

if [ "$BASE_BRANCH" = "$MASTER_BRANCH" ]; then
# By default we back-merge the $MASTER_BRANCH unless the user explicitly
# stated not to do a back-merge, in that case we use the $BRANCH.
if noflag nobackmerge; then
MERGE_BRANCH="$BASE_BRANCH"
else
MERGE_BRANCH="$BRANCH"
fi

# Try to merge into develop.
if [ "$BASE_BRANCH" = "$MASTER_BRANCH" ] && noflag nobackmerge && noflag cherrypick; then
# Try to merge into develop unless the user specified the nobackmerge option.
# 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 "$MERGE_BRANCH" "$DEVELOP_BRANCH"; then
if ! git_is_branch_merged_into "$BASE_BRANCH" "$DEVELOP_BRANCH"; then
# Accounting for 'git describe', if a release is tagged
# we use the tag commit instead of the branch.
if noflag notag; then
commit="$VERSION_PREFIX$TAGNAME"
else
commit="$BASE_BRANCH"
fi
# merge master to develop
git_do checkout "$DEVELOP_BRANCH" || die "Could not check out branch '$DEVELOP_BRANCH'."
git_do merge --no-ff "$commit" || die "There were merge conflicts." # TODO: What do we do now?
fi
fi

if noflag nobackmerge; then
# Accounting for 'git describe', if a release is tagged
# we use the tag commit instead of the branch.
if noflag notag; then
commit="$VERSION_PREFIX$TAGNAME"
else
commit="$BASE_BRANCH"
fi
if flag releasebackmerge; then
_releasePrefix=$(git config --get gitflow.prefix.release)
release_branches=$(git_local_branches_prefixed "$_releasePrefix")
release_branch=
# Check if there is a release branch
if [ -n "$release_branches" ]; then
# Get the release branch name
release_branch=$(echo ${release_branches} | head -n1)
# Check if release branch exists on remote
if git_remote_branch_exists "$ORIGIN/$release_branch"; then
# Try to merge into release.
# In case a previous attempt to finish this release branch has failed,
# but the merge into release was successful, we skip it now
if ! git_is_branch_merged_into "$MERGE_BRANCH" "$release_branch"; then
git_do checkout "$release_branch" || die "Could not check out branch '$release_branch'."
# Accounting for 'git describe', if a release is tagged
# we use the tag commit instead of the branch.
if noflag notag; then
commit="$VERSION_PREFIX$TAGNAME"
else
commit="$BASE_BRANCH"
fi
else
commit="$BRANCH"
fi
git_do merge --no-ff "$commit" || die "There were merge conflicts."
# TODO: What do we do now?
else
commit="$BRANCH"
echo "Remote release $release_branch not found"
fi

git_do merge --no-ff "$commit" || die "There were merge conflicts."
# TODO: What do we do now?
fi
fi
fi

run_post_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH"

if flag push; then
if [ "$BASE_BRANCH" = "$MASTER_BRANCH" ]; then
git_do push "$ORIGIN" "$DEVELOP_BRANCH" || die "Could not push branch '$DEVELOP_BRANCH' to remote '$ORIGIN'."
fi
if [ -n "$release_branch" ]; then
git_do push "$ORIGIN" "$release_branch" || dir "Could not push branch '$release_branch' to remote '$ORIGIN'."
fi
git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'."
if noflag notag; then
git_do push --tags "$ORIGIN" || die "Could not push tags to remote '$ORIGIN'."
Expand Down Expand Up @@ -633,11 +712,15 @@ T,tagname! Use given tag name
if noflag notag; then
echo "- The hotfix was tagged '$VERSION_PREFIX$TAGNAME'"
fi
if [ "$BASE_BRANCH" = "$MASTER_BRANCH" ]; then
if flag cherrypick; then
echo "- All commits from the hotfix branch have been cherry picked into '$DEVELOP_BRANCH'"
elif [ "$BASE_BRANCH" = "$MASTER_BRANCH" ]; then
[ "$commit" = "$BASE_BRANCH" ] && echo "- Master branch '$BASE_BRANCH' has been back-merged into '$DEVELOP_BRANCH'"
[ "$commit" = "$VERSION_PREFIX$TAGNAME" ] && echo "- Hotfix tag '$VERSION_PREFIX$TAGNAME' has been back-merged into '$DEVELOP_BRANCH'"
[ -n "$release_branch" ] && echo "- Hotfix tag '$VERSION_PREFIX$TAGNAME' has been back-merged into '$release_branch'"
[ "$commit" = "$VERSION_PREFIX$VERSION" ] && echo "- Hotfix tag '$VERSION_PREFIX$VERSION' has been back-merged into '$DEVELOP_BRANCH'"
[ "$commit" = "$BRANCH" ] && echo "- Hotfix branch '$BRANCH' has been merged into '$DEVELOP_BRANCH'"
fi

if noflag keep; then
if [ $localbranchdeleted -eq $FLAGS_TRUE ]; then
keepmsg="has been locally deleted"
Expand Down
Loading

0 comments on commit 56cd71a

Please sign in to comment.