Skip to content

Commit

Permalink
add a pre commit git check
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-james committed May 31, 2024
1 parent 94e2bc7 commit 8032279
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -e

# stash any unstaged changes
git stash push -m "prePush" -q --keep-index

# unstash the unstashed changes (if any) on exit or interrupt
function unstash {
git stash apply stash^{/prePush} -q || true
}

trap unstash EXIT

./gradlew check test -q
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,9 @@ javadoc {
options.showFromPublic()
}

task setUpGitHooks(type: Exec, description: 'Add a pre-commit git hook that runs gradle check & test tasks') {
def hooksFolder = file('.githooks').getAbsolutePath()
commandLine 'git', 'config', 'core.hooksPath', hooksFolder
}

check.dependsOn integrationTest

0 comments on commit 8032279

Please sign in to comment.