mfrb 693 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env bash
  2. #
  3. # mfrb
  4. #
  5. # Do "git rebase -i" against the "target" branch (bugfix-1.1.x, bugfix-2.0.x, or master)
  6. #
  7. MFINFO=$(mfinfo "$@") || exit 1
  8. IFS=' ' read -a INFO <<< "$MFINFO"
  9. TARG=${INFO[3]}
  10. CURR=${INFO[5]}
  11. IND=6
  12. while [ $IND -lt ${#INFO[@]} ]; do
  13. ARG=${INFO[$IND]}
  14. case "$ARG" in
  15. -q|--quick ) QUICK=1 ;;
  16. -h|--help ) USAGE=1 ;;
  17. * ) USAGE=1 ; echo "unknown option: $ARG" ;;
  18. esac
  19. let IND+=1
  20. done
  21. [[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2]" 1>&2 ; exit 1 ; }
  22. # If the branch isn't currently the PR target
  23. if [[ $TARG != $CURR ]]; then
  24. [[ $QUICK ]] || git fetch upstream
  25. git rebase upstream/$TARG && git rebase -i upstream/$TARG
  26. fi