mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-02 08:58:23 +02:00
Adding pre-commit git hook
This commit is contained in:
parent
f8d6cf8dba
commit
c4c8c0fbf7
@ -108,6 +108,14 @@ Build the app:
|
||||
./gradlew installDebug
|
||||
```
|
||||
|
||||
## Git Hooks
|
||||
|
||||
You can add the git hook running the following bash script:
|
||||
|
||||
```bash
|
||||
./tools/git-hooks/init.sh
|
||||
```
|
||||
|
||||
## How to Deploy
|
||||
|
||||
1. Generate a new signing key
|
||||
|
13
tools/git-hooks/init.sh
Executable file
13
tools/git-hooks/init.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
function setup_git_hooks()
|
||||
{
|
||||
echo "Initialising git hooks..."
|
||||
ln -sf "$PWD/tools/git-hooks/pre-commit.sh" "$PWD/.git/hooks/pre-commit"
|
||||
chmod +x "$PWD/.git/hooks/pre-commit"
|
||||
echo "Done"
|
||||
}
|
||||
|
||||
setup_git_hooks
|
23
tools/git-hooks/pre-commit.sh
Executable file
23
tools/git-hooks/pre-commit.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
NO_COLOR='\033[0m'
|
||||
|
||||
echo "*********************************************************"
|
||||
echo "Running git pre-commit hook. Running Static analysis... "
|
||||
echo "*********************************************************"
|
||||
|
||||
./gradlew ktlintCheck
|
||||
|
||||
status=$?
|
||||
|
||||
if [ "$status" = 0 ] ; then
|
||||
echo "Static analysis found no problems."
|
||||
exit 0
|
||||
else
|
||||
echo "*********************************************************"
|
||||
echo 1>&2 "Static analysis found violations it could not fix."
|
||||
printf "Run ${GREEN}./gradlew ktlintFormat${NO_COLOR} to fix formatting related issues...\n"
|
||||
echo "*********************************************************"
|
||||
exit 1
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user