Skip to content

Commit

Permalink
chore: pre-commit 시 spotlessApply 실행 (#412)
Browse files Browse the repository at this point in the history
* fix: pre-commit test
  • Loading branch information
char-yb authored Jun 21, 2024
1 parent dcbe752 commit 5dc5415
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ spotless {

// pre-commit spotless check script
tasks.register('updateGitHooks', Copy) {
from './scripts/pre-commit'
into './.git/hooks'
from 'scripts/pre-commit'
into '.git/hooks'
}
compileJava.dependsOn updateGitHooks
23 changes: 13 additions & 10 deletions scripts/pre-commit
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash
echo "Running spotless check"
./gradlew spotlessCheck
if [ \$? -eq 0 ]
then
echo "Spotless check succeed"
else
echo "Spotless check failed" >&2
exit 1
fi
#!/bin/sh

targetFiles=$(git diff --staged --name-only)

echo "Apply Spotless.."
./gradlew spotlessApply

# Add files to stage spotless applied
for file in $targetFiles; do
if test -f "$file"; then
git add $file
fi
done

0 comments on commit 5dc5415

Please sign in to comment.