mfqp 844 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env bash
  2. #
  3. # mfqp [-q|--quick] [1|2|3]
  4. #
  5. # Add all changed files, commit as "patch", do `mfrb` and `git push -f`
  6. #
  7. MFINFO=$(mfinfo "$@") || exit 1
  8. IFS=' ' read -a INFO <<< "$MFINFO"
  9. REPO=${INFO[2]}
  10. TARG=${INFO[3]}
  11. CURR=${INFO[5]}
  12. IND=6
  13. while [ $IND -lt ${#INFO[@]} ]; do
  14. ARG=${INFO[$IND]}
  15. case "$ARG" in
  16. -q|--quick ) QUICK="-q" ;;
  17. -h|--help ) USAGE=1 ;;
  18. * ) USAGE=1 ; echo "unknown option: $ARG" ;;
  19. esac
  20. let IND+=1
  21. done
  22. [[ ${INFO[4]} =~ [0-9] ]] && USAGE=1
  23. [[ $USAGE == 1 ]] && { echo "usage: `basename $0` [-hq] [1|2|3]" 1>&2 ; exit 1 ; }
  24. git add .
  25. git commit -m "patch"
  26. if [[ $CURR == $TARG ]]; then
  27. if [[ $REPO == "MarlinDocumentation" ]]; then
  28. git rebase -i HEAD~2 && git push -f
  29. else
  30. echo "Don't alter the PR Target branch."; exit 1
  31. fi
  32. else
  33. mfrb $QUICK "$@" && git push -f
  34. fi