https://github.com/pepperkit/git-hooks-gradle-plugin
Gradle plugin for easy git hooks configuration.
https://github.com/pepperkit/git-hooks-gradle-plugin
git git-hooks gradle gradle-plugin java
Last synced: 4 months ago
JSON representation
Gradle plugin for easy git hooks configuration.
- Host: GitHub
- URL: https://github.com/pepperkit/git-hooks-gradle-plugin
- Owner: pepperkit
- License: mit
- Created: 2023-08-08T08:43:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-15T00:26:23.000Z (almost 2 years ago)
- Last Synced: 2025-03-05T00:30:47.985Z (over 1 year ago)
- Topics: git, git-hooks, gradle, gradle-plugin, java
- Language: Java
- Homepage:
- Size: 91.8 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Git Hooks Gradle Plugin
[](https://github.com/pepperkit/git-hooks-gradle-plugin/actions/workflows/build.yml)
[](https://sonarcloud.io/dashboard?id=pepperkit_git-hooks-gradle-plugin)
[](https://sonarcloud.io/dashboard?id=pepperkit_git-hooks-gradle-plugin)
[](https://sonarcloud.io/dashboard?id=pepperkit_git-hooks-gradle-plugin)
[](https://sonarcloud.io/dashboard?id=pepperkit_git-hooks-gradle-plugin)
Gradle plugin for easy git hooks configuration.
## Usage
Add the plugin into your `build.gradle`, configure the hooks, and optionally configure the build task to be dependant
initGitHooks task, to install the hooks each time the project is rebuild.
The example with *pre-commit* and *pre-push* hooks configured, will look like this:
```groovy
plugins {
id 'io.github.pepperkit.git-hooks-gradle-plugin' version '1.0.0'
}
compileJava {
// Initialize git hooks each time the project is compiled
dependsOn initGitHooks
}
gitHooksGradlePlugin {
hooks = [
// Run checkstyle plugin before each commit attempt
'pre-commit' : 'gradle -q checkstyleMain',
// Run unit tests before each push attempt
'pre-push' : 'gradle -q test'
]
}
```
Hook's content is any command line script, which is considered successful if exit code is equal to `0`, and not otherwise.
If execution of the script is successful, git action will be proceeded, if not - it will be cancelled.
## Project's structure
```
└── src
├── main # code of the plugin
├── test # unit tests
└── system-test # system tests
└── resources # system tests scenarios and pre-configured gradle files needed for the tests
```
More about pepperkit projects could be found on its website: https://pepperkit.github.io/