Skip to content

Instantly share code, notes, and snippets.

@strootman
Forked from chadmaughan/pre-commit.sh
Last active May 20, 2019 03:41
Show Gist options
  • Select an option

  • Save strootman/39c46a178de639f62f74 to your computer and use it in GitHub Desktop.

Select an option

Save strootman/39c46a178de639f62f74 to your computer and use it in GitHub Desktop.

Revisions

  1. Jonathan D Strootman renamed this gist Aug 19, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion pre-commit.sh → pre-push
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,8 @@
    git stash -q --keep-index

    # run the tests with the gradle wrapper
    ./gradlew test
    ./gradlew test -q
    # Another possibility could be to run an aggregate test report task and automatically open the generated html

    # store the last exit code in a variable
    RESULT=$?
  2. @chadmaughan chadmaughan revised this gist Jun 29, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pre-commit.sh
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    git stash -q --keep-index

    # run the tests with the gradle wrapper
    ./gradlew test -q
    ./gradlew test

    # store the last exit code in a variable
    RESULT=$?
  3. @chadmaughan chadmaughan created this gist Jun 29, 2013.
    24 changes: 24 additions & 0 deletions pre-commit.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/sh
    # this hook is in SCM so that it can be shared
    # to install it, create a symbolic link in the projects .git/hooks folder
    #
    # i.e. - from the .git/hooks directory, run
    # $ ln -s ../../git-hooks/pre-commit.sh pre-commit
    #
    # to skip the tests, run with the --no-verify argument
    # i.e. - $ 'git commit --no-verify'

    # stash any unstaged changes
    git stash -q --keep-index

    # run the tests with the gradle wrapper
    ./gradlew test -q

    # store the last exit code in a variable
    RESULT=$?

    # unstash the unstashed changes
    git stash pop -q

    # return the './gradlew test' exit code
    exit $RESULT