mirror of
https://github.com/tj/git-extras.git
synced 2026-09-12 16:36:22 -04:00
add squash option to git-feature
This commit is contained in:
commit
c038741194
|
|
@ -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 <name>
|
||||
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 <name>
|
||||
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" "<name> 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" "<name> 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" "<name> 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" "<name> 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
<finish>
|
||||
.
|
||||
.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
|
||||
.
|
||||
|
|
|
|||
|
|
@ -92,6 +92,10 @@
|
|||
|
||||
<p> Setup a remote tracking branch using <code>remote_name</code>. If <code>remote_name</code> is not supplied, use <code>origin</code> by default.</p>
|
||||
|
||||
<p> <--squash></p>
|
||||
|
||||
<p> Run a squash merge.</p>
|
||||
|
||||
<p> <finish></p>
|
||||
|
||||
<p> Merge and delete the feature branch.</p>
|
||||
|
|
@ -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
|
||||
</code></pre>
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Jesús Espino <<a href="mailto:jespinog@gmail.com" data-bare-link="true">jespinog@gmail.com</a>><br />
|
||||
Modified by Mark Pitman <<a href="mailto:mark.pitman@gmail.com" data-bare-link="true">mark.pitman@gmail.com</a>></p>
|
||||
<p>Written by Jesús Espino <<a href="mailto:jespinog@gmail.com" data-bare-link="true">jespinog@gmail.com</a>><br />
|
||||
Modified by Mark Pitman <<a href="mailto:mark.pitman@gmail.com" data-bare-link="true">mark.pitman@gmail.com</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
@ -134,7 +138,7 @@ Modified by Mark Pitman <<a href="mailto:
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>October 2017</li>
|
||||
<li class='tc'>April 2020</li>
|
||||
<li class='tr'>git-feature(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ git-feature(1) -- Create/Merge feature branch
|
|||
|
||||
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.
|
||||
|
|
@ -40,7 +44,7 @@ git-feature(1) -- Create/Merge feature branch
|
|||
$ git features dependencies
|
||||
$ (features/dependencies) ...
|
||||
$ (features/dependencies) git checkout master
|
||||
$ git features finish dependencies
|
||||
$ git features finish --squash dependencies
|
||||
|
||||
$ git feature dependencies -r upstream
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue