Skip to content

Commit

Permalink
[feat] add automated pre push trunk fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryang20718 committed Jun 17, 2024
1 parent f9d580b commit 318579d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions actions/trunk/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ actions:
- git_hooks: [pre-commit]
notify_on_error: false

- id: trunk-fmt-pre-push
description: Run 'trunk fmt' whenever you run 'git push'
display_name: Trunk Fmt Pre-Push Hook
run: |
if [[ `git status --porcelain` ]]; then
# git workspace is not clean. user has unchecked files
echo "git has unchecked files. please commit them before git push"
exit 1
else
trunk fmt
if [[ `git status --porcelain` ]]; then
git add .
git commit -m "[automated git commit] trunk fmt"
fi
fi
interactive: optional
triggers:
- git_hooks: [pre-push]
notify_on_error: false

# We do not auto-suggest turning on check pre-commit for several reasons:
# - Linters can often be much slower than formatters, and we don't want to unnecessarily block iteration.
# - The trunk-fmt-pre-commit action is usually sufficient for enforcing style.
Expand Down

0 comments on commit 318579d

Please sign in to comment.