From 8a4c165be6705b5ab9be34829c8d22c91a15c522 Mon Sep 17 00:00:00 2001 From: Sergiy Popovych Date: Fri, 2 Feb 2024 12:13:42 +0000 Subject: [PATCH] feat: add pre-commit check for `internal` branch --- .pre-commit-config.yaml | 9 +++++++++ check_submodule_version.sh | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 check_submodule_version.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index beb56e3f0..e3e566084 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,6 +21,15 @@ repos: stages: [commit] language: system entry: jupyter nbconvert --to notebook --ClearOutputPreprocessor.enabled=True --inplace +- repo: local + hooks: + - id: internal-is-on-main + name: internal-is-on-main + stages: [commit] + language: system + entry: ./check_submodule_version.sh + always_run: true + - repo: local hooks: - id: reveal_type diff --git a/check_submodule_version.sh b/check_submodule_version.sh new file mode 100755 index 000000000..4f6c3b694 --- /dev/null +++ b/check_submodule_version.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +SCRIPT_DIR=$(dirname "$0") +TARGET_DIR="$SCRIPT_DIR/zetta_utils/internal" + +cd $TARGET_DIR + +if git merge-base --is-ancestor HEAD origin/main; then + echo "Submodule's commit is on the main branch." +else + echo "Error: Submodule's commit is not on the main branch." + exit 1 +fi + +cd -