Browse Source

🔨 Update git helper scripts

vanilla_fb_2.0.x
Scott Lahteine 3 years ago
committed by Scott Lahteine
parent
commit
5efef86cfa
  1. 14
      buildroot/share/git/mffp
  2. 28
      buildroot/share/git/mfinfo
  3. 6
      buildroot/share/git/mfnew
  4. 6
      buildroot/share/git/mfpr
  5. 4
      buildroot/share/git/mfqp
  6. 4
      buildroot/share/git/mfrb

14
buildroot/share/git/mffp

@ -1,19 +1,23 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# mffp [1|2|3] [commit-id] # mffp [1|2] [ref]
# #
# Push the given commit (or HEAD) upstream immediately. # 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 MFINFO=$(mfinfo "$1") || exit 1
REF=${2:-HEAD} REF=${2:-HEAD}
else elif [[ $# == 1 ]]; then
MFINFO=$(mfinfo) || exit 1 MFINFO=$(mfinfo) || exit 1
REF=${1:-HEAD} REF=${1:-HEAD}
else
usage
fi fi
IFS=' ' read -a INFO <<< "$MFINFO" IFS=' ' read -a INFO <<< "$MFINFO"

28
buildroot/share/git/mfinfo

@ -2,15 +2,19 @@
# #
# mfinfo # mfinfo
# #
# Provide the following info about the working directory: # Print the following info about the working copy:
# #
# - Remote (upstream) Org name (MarlinFirmware) # - Remote (upstream) Org name (MarlinFirmware)
# - Remote (origin) Org name (your Github username) # - Remote (origin) Org name (your Github username)
# - Repo Name (Marlin, MarlinDocumentation) # - 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) # - Branch Arg (the branch argument or current branch)
# - 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') CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
[[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; } [[ -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 # Defaults if no arguments given
BRANCH=$CURR BRANCH=$CURR
INDEX=1 MORE=""
INDEX=2
# Loop through arguments
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
# Get an arg and maybe a val to go with it
opt="$1" ; shift ; val="$1" opt="$1" ; shift ; val="$1"
# Split up an arg containing =
IFS='=' read -a PARTS <<<"$opt" IFS='=' read -a PARTS <<<"$opt"
[[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; } [[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; }
GOODVAL=1
if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then
GOODVAL=0
val="" val=""
fi fi
case "$opt" in case "$opt" in
-*|--*) MORE="$MORE$opt " ; [[ $EQUALS == 1 ]] && MORE="$MORE=$val" ;; -*|--*) MORE=" $MORE$opt" ; ((EQUALS)) && MORE="$MORE=$val" ;;
1|2|3) INDEX=$opt ;; 1|2) INDEX=$opt ;;
*) BRANCH="$opt" ;; *) BRANCH="$opt" ;;
esac esac
done done
case "$REPO" in 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 ;; Configurations ) TARG=import-2.0.x ;;
MarlinDocumentation ) TARG=master ;; MarlinDocumentation ) TARG=master ;;
AutoBuildMarlin ) TARG=master ;; AutoBuildMarlin ) TARG=master ;;
esac 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
buildroot/share/git/mfnew

@ -6,7 +6,7 @@
# #
usage() { 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; } [[ $# < 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 # BRANCH can be given as the last argument
case "$#" in case "$#" in
1 ) case "$1" in 1 ) case "$1" in
1|2|3) ;; 1|2) ;;
*) BRANCH=$1 ;; *) BRANCH=$1 ;;
esac esac
;; ;;
2 ) case "$1" in 2 ) case "$1" in
1|2|3) BRANCH=$2 ;; 1|2) BRANCH=$2 ;;
*) usage ; exit 1 ;; *) usage ; exit 1 ;;
esac esac
;; ;;

6
buildroot/share/git/mfpr

@ -1,11 +1,11 @@
#!/usr/bin/env bash #!/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 MFINFO=$(mfinfo "$@") || exit 1
IFS=' ' read -a INFO <<< "$MFINFO" IFS=' ' read -a INFO <<< "$MFINFO"

4
buildroot/share/git/mfqp

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# mfqp [1|2|3] # mfqp [1|2]
# #
# - git add . # - git add .
# - git commit --amend # - git commit --amend
@ -24,7 +24,7 @@ while [ $IND -lt ${#INFO[@]} ]; do
let IND+=1 let IND+=1
done 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 ; } [[ $FORCE != 1 && $CURR == $TARG && $REPO != "MarlinDocumentation" ]] && { echo "Don't alter the PR Target branch."; exit 1 ; }

4
buildroot/share/git/mfrb

@ -2,7 +2,7 @@
# #
# mfrb # 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 MFINFO=$(mfinfo "$@") || exit 1
@ -21,7 +21,7 @@ while [ $IND -lt ${#INFO[@]} ]; do
let IND+=1 let IND+=1
done 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 [[ $QUICK ]] || git fetch upstream
git rebase upstream/$TARG && git rebase -i upstream/$TARG git rebase upstream/$TARG && git rebase -i upstream/$TARG

Loading…
Cancel
Save