tools/op: add switch command (#34112)

* tools/op: add switch command

* fix

* .

* usage

* fix

---------

Co-authored-by: Maxime Desroches <desroches.maxime@gmail.com>
pull/34146/head
Adeeb Shihadeh 5 months ago committed by GitHub
parent 43807746ff
commit b33441213a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 28
      tools/op.sh

@ -94,7 +94,7 @@ function op_check_git() {
fi fi
echo "Checking for git lfs files..." 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." echo -e " ↳ [${GREEN}${NC}] git lfs files found."
else else
echo -e " ↳ [${RED}${NC}] git lfs files not found! Run 'git lfs pull'" 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 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] <BRANCH>"
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() { function op_default() {
echo "An openpilot helper" echo "An openpilot helper"
echo "" echo ""
@ -333,6 +357,7 @@ function op_default() {
echo -e " ${BOLD}setup${NC} Install openpilot dependencies" 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}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}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 ""
echo -e "${BOLD}${UNDERLINE}Commands [Tooling]:${NC}" echo -e "${BOLD}${UNDERLINE}Commands [Tooling]:${NC}"
echo -e " ${BOLD}juggle${NC} Run PlotJuggler" echo -e " ${BOLD}juggle${NC} Run PlotJuggler"
@ -388,6 +413,7 @@ function _op() {
replay ) shift 1; op_replay "$@" ;; replay ) shift 1; op_replay "$@" ;;
sim ) shift 1; op_sim "$@" ;; sim ) shift 1; op_sim "$@" ;;
install ) shift 1; op_install "$@" ;; install ) shift 1; op_install "$@" ;;
switch ) shift 1; op_switch "$@" ;;
post-commit ) shift 1; op_install_post_commit "$@" ;; post-commit ) shift 1; op_install_post_commit "$@" ;;
* ) op_default "$@" ;; * ) op_default "$@" ;;
esac esac

Loading…
Cancel
Save