feat(sterni/git-only-push): allow using git cherry-pick -x
I've noticed git only-push is quite useful for creating backports for nixpkgs stable branches which we need git cherry-pick -x for. Change-Id: Ie20248d3d0c5fee5cdbd3b3a078439a99f597c02 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12903 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Autosubmit: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
b8342a821b
commit
8459ad94fa
1 changed files with 8 additions and 3 deletions
|
@ -25,7 +25,7 @@ die() {
|
|||
|
||||
usage() {
|
||||
printf '%s\n' \
|
||||
"git only-push [-n] [-b <rev>] -r <remote> -t <refspec> [--] <commit>..." \
|
||||
"git only-push [-n] [-x] [-b <rev>] -r <remote> -t <refspec> [--] <commit>..." \
|
||||
>&2
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ base=refs/remotes/origin/HEAD
|
|||
dry=false
|
||||
|
||||
# TODO(sterni): non-interactive mode, e.g. clean up also on cherry-pick failure
|
||||
while getopts "b:r:t:nh" opt; do
|
||||
while getopts "b:r:t:nxh" opt; do
|
||||
case $opt in
|
||||
# TODO(sterni): it is probably too close to --branch?
|
||||
b)
|
||||
|
@ -48,13 +48,18 @@ while getopts "b:r:t:nh" opt; do
|
|||
n)
|
||||
dry=true
|
||||
;;
|
||||
x)
|
||||
cherry_pick_x=true
|
||||
;;
|
||||
h|?)
|
||||
usage
|
||||
# TODO(sterni): add man page
|
||||
# shellcheck disable=SC2016
|
||||
[ "$opt" = "h" ] && printf '
|
||||
\t-r <remote>\tRemote to push to.
|
||||
\t-t <refspec>\tTarget ref to push to.
|
||||
\t-b <rev>\tOptional: Base revision to cherry-pick commits onto. Defaults to refs/remotes/origin/HEAD.
|
||||
\t-x\t\tUse `git cherry-pick -x` for creating cherry-picks.
|
||||
\t-n\t\tDry run.
|
||||
'
|
||||
[ "$opt" = "h" ] && exit 0 || exit 100
|
||||
|
@ -106,7 +111,7 @@ for rev in $revs; do
|
|||
printf 'Would cherry pick %s\n' "$rev" >&2
|
||||
else
|
||||
no_cherry_pick=false
|
||||
git cherry-pick "$rev" || no_cherry_pick=true
|
||||
git cherry-pick ${cherry_pick_x:+-x} "$rev" || no_cherry_pick=true
|
||||
if $no_cherry_pick; then
|
||||
tmp="$worktree"
|
||||
# Prevent cleanup from removing the worktree
|
||||
|
|
Loading…
Reference in a new issue