Skip to content

Commit

Permalink
Avoid accidental pushes to develop and trunk (#8287)
Browse files Browse the repository at this point in the history
Co-authored-by: Timur Karimov <[email protected]>
  • Loading branch information
timur27 and Timur Karimov authored Mar 1, 2024
1 parent c8fd975 commit 4053d9d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
. "$(dirname "$0")/_/husky.sh"

# Allows us to read user input below, redirects script's input to the terminal.
exec < /dev/tty

PROTECTED_BRANCH=("develop" "trunk")
CURRENT_BRANCH=$(git branch --show-current)

if [[ " ${PROTECTED_BRANCH[@]} " =~ " ${CURRENT_BRANCH} " ]]; then
read -p "$CURRENT_BRANCH is a protected branch. Are you sure you want to push? (y/n): " confirmation
if [ "$confirmation" != "y" ]; then
echo "Push aborted"
exit 1
fi
fi
4 changes: 4 additions & 0 deletions changelog/avoid-accidental-push-to-develop
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Dev: additional check when pushing to protected branches.

0 comments on commit 4053d9d

Please sign in to comment.