🔨 Update git helper scripts
This commit is contained in:
parent
20c747753d
commit
5efef86cfa
|
@ -1,19 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# mffp [1|2|3] [commit-id]
|
||||
# mffp [1|2] [ref]
|
||||
#
|
||||
# Push the given commit (or HEAD) upstream immediately.
|
||||
# By default: `git push upstream HEAD:bugfix-1.1.x`
|
||||
# By default: `git push upstream HEAD:bugfix-2.0.x`
|
||||
#
|
||||
|
||||
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2|3] [commit-id]" 1>&2 ; exit 1; }
|
||||
usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 }
|
||||
|
||||
if [[ $1 == '1' || $1 == '2' || $1 == '3' ]]; then
|
||||
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage ; exit 1; }
|
||||
|
||||
if [[ $1 == '1' || $1 == '2' ]]; then
|
||||
MFINFO=$(mfinfo "$1") || exit 1
|
||||
REF=${2:-HEAD}
|
||||
else
|
||||
elif [[ $# == 1 ]]; then
|
||||
MFINFO=$(mfinfo) || exit 1
|
||||
REF=${1:-HEAD}
|
||||
else
|
||||
usage
|
||||
fi
|
||||
|
||||
IFS=' ' read -a INFO <<< "$MFINFO"
|
||||
|
|
|
@ -2,15 +2,19 @@
|
|||
#
|
||||
# mfinfo
|
||||
#
|
||||
# Provide the following info about the working directory:
|
||||
# Print the following info about the working copy:
|
||||
#
|
||||
# - Remote (upstream) Org name (MarlinFirmware)
|
||||
# - Remote (origin) Org name (your Github username)
|
||||
# - Repo Name (Marlin, MarlinDocumentation)
|
||||
# - PR Target branch (bugfix-1.1.x, bugfix-2.0.x, dev-2.1.x, etc.)
|
||||
# - PR Target branch (e.g., bugfix-2.0.x)
|
||||
# - Branch Arg (the branch argument or current branch)
|
||||
# - Current Branch
|
||||
#
|
||||
# Example output
|
||||
# > mfinfo -q ongoing
|
||||
# MarlinFirmware john.doe Marlin bugfix-2.0.x ongoing bugfix-2.0.x -q
|
||||
#
|
||||
|
||||
CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
|
||||
[[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
|
||||
|
@ -26,37 +30,37 @@ FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
|
|||
|
||||
# Defaults if no arguments given
|
||||
BRANCH=$CURR
|
||||
INDEX=1
|
||||
MORE=""
|
||||
INDEX=2
|
||||
|
||||
# Loop through arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
# Get an arg and maybe a val to go with it
|
||||
opt="$1" ; shift ; val="$1"
|
||||
|
||||
# Split up an arg containing =
|
||||
IFS='=' read -a PARTS <<<"$opt"
|
||||
[[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; }
|
||||
|
||||
GOODVAL=1
|
||||
if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then
|
||||
GOODVAL=0
|
||||
val=""
|
||||
fi
|
||||
|
||||
case "$opt" in
|
||||
-*|--*) MORE="$MORE$opt " ; [[ $EQUALS == 1 ]] && MORE="$MORE=$val" ;;
|
||||
1|2|3) INDEX=$opt ;;
|
||||
-*|--*) MORE=" $MORE$opt" ; ((EQUALS)) && MORE="$MORE=$val" ;;
|
||||
1|2) INDEX=$opt ;;
|
||||
*) BRANCH="$opt" ;;
|
||||
esac
|
||||
|
||||
done
|
||||
|
||||
case "$REPO" in
|
||||
Marlin ) TARG=bugfix-2.0.x ; [[ $INDEX == 1 ]] && TARG=bugfix-1.1.x ; [[ $INDEX == 3 ]] && TARG=dev-2.1.x ;;
|
||||
Marlin ) TARG=bugfix-2.0.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;;
|
||||
Configurations ) TARG=import-2.0.x ;;
|
||||
MarlinDocumentation ) TARG=master ;;
|
||||
AutoBuildMarlin ) TARG=master ;;
|
||||
esac
|
||||
|
||||
[[ $BRANCH =~ ^[123]$ ]] && USAGE=1
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1 ; }
|
||||
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3] [branch]" 1>&2 ; exit 1 ; }
|
||||
|
||||
echo "$ORG $FORK $REPO $TARG $BRANCH $CURR $MORE"
|
||||
echo "$ORG $FORK $REPO $TARG $BRANCH $CURR$MORE"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
|
||||
usage() {
|
||||
echo "usage: `basename $0` [1|2|3] [name]" 1>&2
|
||||
echo "usage: `basename $0` [1|2] [name]" 1>&2
|
||||
}
|
||||
|
||||
[[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; }
|
||||
|
@ -19,12 +19,12 @@ BRANCH=pr_for_$TARG-$(date +"%G-%m-%d_%H.%M.%S")
|
|||
# BRANCH can be given as the last argument
|
||||
case "$#" in
|
||||
1 ) case "$1" in
|
||||
1|2|3) ;;
|
||||
1|2) ;;
|
||||
*) BRANCH=$1 ;;
|
||||
esac
|
||||
;;
|
||||
2 ) case "$1" in
|
||||
1|2|3) BRANCH=$2 ;;
|
||||
1|2) BRANCH=$2 ;;
|
||||
*) usage ; exit 1 ;;
|
||||
esac
|
||||
;;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# mfpr [1|2|3]
|
||||
# mfpr [1|2]
|
||||
#
|
||||
# Make a PR against bugfix-1.1.x or bugfix-2.0.x
|
||||
# Make a PR targeted to MarlinFirmware/[repo]
|
||||
#
|
||||
|
||||
[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2|3] [branch]" 1>&2 ; exit 1; }
|
||||
[[ $# < 2 && $1 != "-h" && $1 != "--help" ]] || { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1; }
|
||||
|
||||
MFINFO=$(mfinfo "$@") || exit 1
|
||||
IFS=' ' read -a INFO <<< "$MFINFO"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# mfqp [1|2|3]
|
||||
# mfqp [1|2]
|
||||
#
|
||||
# - git add .
|
||||
# - git commit --amend
|
||||
|
@ -24,7 +24,7 @@ while [ $IND -lt ${#INFO[@]} ]; do
|
|||
let IND+=1
|
||||
done
|
||||
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; }
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; }
|
||||
|
||||
[[ $FORCE != 1 && $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# mfrb
|
||||
#
|
||||
# Do "git rebase -i" against the "target" branch (bugfix-1.1.x, bugfix-2.0.x, dev-2.1.x, or master)
|
||||
# Do "git rebase -i" against the repo's "target" branch
|
||||
#
|
||||
|
||||
MFINFO=$(mfinfo "$@") || exit 1
|
||||
|
@ -21,7 +21,7 @@ while [ $IND -lt ${#INFO[@]} ]; do
|
|||
let IND+=1
|
||||
done
|
||||
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2|3]" 1>&2 ; exit 1 ; }
|
||||
[[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; }
|
||||
|
||||
[[ $QUICK ]] || git fetch upstream
|
||||
git rebase upstream/$TARG && git rebase -i upstream/$TARG
|
||||
|
|
Loading…
Reference in a new issue