diff --git a/bin/git-feature b/bin/git-feature index cc2ff20..6872ad9 100755 --- a/bin/git-feature +++ b/bin/git-feature @@ -1,55 +1,59 @@ #!/usr/bin/env bash branch_prefix=feature +merge_mode="--no-ff" declare -a argv while test $# != 0 do - case $1 in - -a|--alias ) - if [[ -n $2 ]] - then - shift # shift -a|-alias - branch_prefix=$1 - else - argv+=($1) # treat tail '-a' as - fi - ;; - -r|--remote ) - if [[ -n $2 ]] - then - remote=$2 - shift - else - remote="origin" - fi - ;; - * ) - argv+=($1) - ;; - esac - shift + case $1 in + -a|--alias ) + if [[ -n $2 ]] + then + shift # shift -a|-alias + branch_prefix=$1 + else + argv+=($1) # treat tail '-a' as + fi + ;; + -r|--remote ) + if [[ -n $2 ]] + then + remote=$2 + shift + else + remote="origin" + fi + ;; + --squash ) + merge_mode="--squash" + ;; + * ) + argv+=($1) + ;; + esac + shift done -concatargs(){ - str=$(IFS='-'; echo "$*") - branch="$branch_prefix"/$str +concatargs() { + str=$(IFS='-'; echo "$*") + branch="$branch_prefix"/$str } if test "${argv[0]}" = "finish"; then - test -z "${argv[1]}" && echo "$branch_prefix" " required." 1>&2 && exit 1 - branch="$branch_prefix"/"${argv[1]}" - git merge --no-ff "$branch" && git delete-branch "$branch" + test -z "${argv[1]}" && echo "$branch_prefix" " required." 1>&2 && exit 1 + branch="$branch_prefix"/"${argv[1]}" + git merge ${merge_mode} "$branch" && git delete-branch "$branch" else - test -z "${argv[0]}" && echo "$branch_prefix" " required." 1>&2 && exit 1 - if test -n "${argv[1]}"; then - concatargs "${argv[@]}" - else - branch="$branch_prefix"/"${argv[0]}" - fi - if [[ -n $remote ]] - then - git create-branch -r $remote $branch - else - git create-branch $branch - fi + test -z "${argv[0]}" && echo "$branch_prefix" " required." 1>&2 && exit 1 + if test -n "${argv[1]}"; then + concatargs "${argv[@]}" + else + branch="$branch_prefix"/"${argv[0]}" + fi + if [[ -n $remote ]] + then + git create-branch -r $remote $branch + else + git create-branch $branch + fi fi diff --git a/man/git-feature.1 b/man/git-feature.1 index ae41d0a..d637a35 100644 --- a/man/git-feature.1 +++ b/man/git-feature.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-FEATURE" "1" "October 2017" "" "Git Extras" +.TH "GIT\-FEATURE" "1" "April 2020" "" "Git Extras" . .SH "NAME" \fBgit\-feature\fR \- Create/Merge feature branch @@ -25,6 +25,12 @@ use \fBbranch_prefix\fR instead of \fBfeature\fR Setup a remote tracking branch using \fBremote_name\fR\. If \fBremote_name\fR is not supplied, use \fBorigin\fR by default\. . .P +<\-\-squash> +. +.P +Run a squash merge\. +. +.P . .P @@ -51,7 +57,7 @@ $ git alias features "feature \-a features" $ git features dependencies $ (features/dependencies) \.\.\. $ (features/dependencies) git checkout master -$ git features finish dependencies +$ git features finish \-\-squash dependencies $ git feature dependencies \-r upstream . diff --git a/man/git-feature.html b/man/git-feature.html index 9fbfbf8..85d6113 100644 --- a/man/git-feature.html +++ b/man/git-feature.html @@ -92,6 +92,10 @@

Setup a remote tracking branch using remote_name. If remote_name is not supplied, use origin by default.

+

<--squash>

+ +

Run a squash merge.

+

<finish>

Merge and delete the feature branch.

@@ -113,15 +117,15 @@ $ git alias features "feature -a features" $ git features dependencies $ (features/dependencies) ... $ (features/dependencies) git checkout master -$ git features finish dependencies +$ git features finish --squash dependencies $ git feature dependencies -r upstream

AUTHOR

-

Written by Jesús Espino <jespinog@gmail.com>
-Modified by Mark Pitman <mark.pitman@gmail.com>

+

Written by Jesús Espino <jespinog@gmail.com>
+Modified by Mark Pitman <mark.pitman@gmail.com>

REPORTING BUGS

@@ -134,7 +138,7 @@ Modified by Mark Pitman <