Skip to content

Commit 4053d9d

Browse files
timur27Timur Karimov
andauthored
Avoid accidental pushes to develop and trunk (#8287)
Co-authored-by: Timur Karimov <[email protected]>
1 parent c8fd975 commit 4053d9d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.husky/pre-push

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
# Allows us to read user input below, redirects script's input to the terminal.
5+
exec < /dev/tty
6+
7+
PROTECTED_BRANCH=("develop" "trunk")
8+
CURRENT_BRANCH=$(git branch --show-current)
9+
10+
if [[ " ${PROTECTED_BRANCH[@]} " =~ " ${CURRENT_BRANCH} " ]]; then
11+
read -p "$CURRENT_BRANCH is a protected branch. Are you sure you want to push? (y/n): " confirmation
12+
if [ "$confirmation" != "y" ]; then
13+
echo "Push aborted"
14+
exit 1
15+
fi
16+
fi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: dev
3+
4+
Dev: additional check when pushing to protected branches.

0 commit comments

Comments
 (0)