Skip to content

Commit 90e6236

Browse files
committed
Lint the main branch when pushing it
1 parent 67bc764 commit 90e6236

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

.husky/pre-push

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44

55
# If the push refs start with (delete), then we're deleting a branch, so skip the pre-push hook
66
# Source: <https://github.com/typicode/husky/issues/169#issuecomment-1719263454>
7-
stdin=$(cat -)
7+
stdin="$(cat -)"
88
if echo "$stdin" | grep -q "^(delete)"; then
99
exit 0
1010
fi
1111

12-
raw_files_to_check="$(git diff main...HEAD --name-only --diff-filter=d)"
12+
current_branch_name="$(git branch --show-current)"
13+
14+
if [[ "$current_branch_name" == "main" ]]; then
15+
raw_files_to_check="$(git diff origin/main...HEAD --name-only --diff-filter=d)"
16+
else
17+
raw_files_to_check="$(git diff main...HEAD --name-only --diff-filter=d)"
18+
fi
19+
1320
if [[ -n "$raw_files_to_check" ]]; then
1421
echo "*** Checking for lint violations in changed files ***************"
1522
echo

0 commit comments

Comments
 (0)