Browse Source

chore: prevent pushing to master with push hook (#46413)

Matt Gaunt-Seo @ Sentry.io 1 year ago
parent
commit
f861f50414
2 changed files with 8 additions and 1 deletions
  1. 7 0
      .pre-commit-config.yaml
  2. 1 1
      scripts/lib.sh

+ 7 - 0
.pre-commit-config.yaml

@@ -60,6 +60,13 @@ repos:
       require_serial: true
       additional_dependencies: [ "pyright@1.1.186" ]
       args: [ '--project', 'pyrightconfig-commithook.json' ]
+    - id: prevent-push
+      name: prevent pushing master
+      stages: [push]
+      entry: bash -c 'test "$PRE_COMMIT_REMOTE_BRANCH" != "refs/heads/master"'
+      always_run: true
+      pass_filenames: false
+      language: system
 
 -   repo: https://github.com/python-jsonschema/check-jsonschema
     rev: 0.21.0

+ 1 - 1
scripts/lib.sh

@@ -126,7 +126,7 @@ setup-git() {
     if ! require pre-commit; then
         pip-install -r requirements-dev.txt
     fi
-    pre-commit install --install-hooks
+    pre-commit install --install-hooks --hook-type pre-commit --hook-type pre-push
     echo ""
 }