Skip to content

Commit

Permalink
Lint the main branch when pushing it
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmire committed Feb 3, 2024
1 parent 67bc764 commit 90e6236
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@

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

raw_files_to_check="$(git diff main...HEAD --name-only --diff-filter=d)"
current_branch_name="$(git branch --show-current)"

if [[ "$current_branch_name" == "main" ]]; then
raw_files_to_check="$(git diff origin/main...HEAD --name-only --diff-filter=d)"
else
raw_files_to_check="$(git diff main...HEAD --name-only --diff-filter=d)"
fi

if [[ -n "$raw_files_to_check" ]]; then
echo "*** Checking for lint violations in changed files ***************"
echo
Expand Down

0 comments on commit 90e6236

Please sign in to comment.