diff --git a/tools/op.sh b/tools/op.sh index 62d390c9b5..f01863e1b1 100755 --- a/tools/op.sh +++ b/tools/op.sh @@ -94,7 +94,7 @@ function op_check_git() { fi echo "Checking for git lfs files..." - if [[ $(file -b $OPENPILOT_ROOT/selfdrive/modeld/models/supercombo.onnx) == "data" ]]; then + if [[ $(file -b $OPENPILOT_ROOT/selfdrive/modeld/models/dmonitoring_model.onnx) == "data" ]]; then echo -e " ↳ [${GREEN}✔${NC}] git lfs files found." else echo -e " ↳ [${RED}✗${NC}] git lfs files not found! Run 'git lfs pull'" @@ -312,6 +312,30 @@ function op_sim() { op_run_command exec tools/sim/launch_openpilot.sh } +function op_switch() { + op_before_cmd + + REMOTE="origin" + if [ "$#" -gt 1 ]; then + REMOTE="$1" + shift + fi + + if [ -z "$1" ]; then + echo -e "${BOLD}${UNDERLINE}Usage:${NC} op switch [REMOTE] " + return 1 + fi + BRANCH="$1" + + git fetch "$REMOTE" "$BRANCH":"$BRANCH" + git checkout -f --recurse-submodules "$BRANCH" + git reset --hard "$BRANCH" + git clean -df + git submodule update --init --recursive + git submodule foreach git reset --hard + git submodule foreach git clean -df +} + function op_default() { echo "An openpilot helper" echo "" @@ -333,6 +357,7 @@ function op_default() { echo -e " ${BOLD}setup${NC} Install openpilot dependencies" echo -e " ${BOLD}build${NC} Run the openpilot build system in the current working directory" echo -e " ${BOLD}install${NC} Install the 'op' tool system wide" + echo -e " ${BOLD}switch${NC} Switch to a different git branch with a clean slate (nukes any changes)" echo "" echo -e "${BOLD}${UNDERLINE}Commands [Tooling]:${NC}" echo -e " ${BOLD}juggle${NC} Run PlotJuggler" @@ -388,6 +413,7 @@ function _op() { replay ) shift 1; op_replay "$@" ;; sim ) shift 1; op_sim "$@" ;; install ) shift 1; op_install "$@" ;; + switch ) shift 1; op_switch "$@" ;; post-commit ) shift 1; op_install_post_commit "$@" ;; * ) op_default "$@" ;; esac