mffp 667 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. #
  3. # mffp [1|2] [ref]
  4. #
  5. # Push the given commit (or HEAD) upstream immediately.
  6. # By default: `git push upstream HEAD:bugfix-2.1.x`
  7. #
  8. usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 ; }
  9. [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage ; exit 1; }
  10. if [[ $1 == '1' || $1 == '2' ]]; then
  11. MFINFO=$(mfinfo "$1") || exit 1
  12. REF=${2:-HEAD}
  13. elif [[ $# == 1 ]]; then
  14. MFINFO=$(mfinfo) || exit 1
  15. REF=${1:-HEAD}
  16. else
  17. usage ; exit 1
  18. fi
  19. IFS=' ' read -a INFO <<< "$MFINFO"
  20. ORG=${INFO[0]}
  21. TARG=${INFO[3]}
  22. if [[ $ORG == "MarlinFirmware" ]]; then
  23. git push upstream $REF:$TARG
  24. else
  25. echo "Not a MarlinFirmware working copy."; exit 1
  26. fi