forked from Kaaveh/ComposeNews
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Kaaveh#248 from Kaaveh/refactor/update_readme
Refactor/update readme
- Loading branch information
Showing
2 changed files
with
60 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,55 @@ | ||
# Git Hooks | ||
|
||
This project has some Git hooks included inside the [git-hooks](/git-hooks) folder. These hooks can be installed automatically via the [setup.sh](/git-hooks/setup.sh) (just windows machine currently, support others OS comming soon). | ||
This project has some Git hooks included inside the [git-hooks](/git-hooks) folder. | ||
|
||
## Pre-Commit | ||
## **Usage Instructions** | ||
|
||
There is a [pre-commit](/git-hooks/pre-commit) hook that will automatically run Ktlint formatting over any modified Kotlin files. This way you can just commit your code and trust that formatting happens behind the scenes, without having to consciously worry about it. | ||
1. **Install Git Hooks**: | ||
- Run the `clean` task to automatically install or update hooks: | ||
```bash | ||
./gradlew clean | ||
``` | ||
|
||
## Pre-Push | ||
2. **Commit-Msg Hook**: | ||
- Ensures commit messages include an issue number (e.g., `#123` or `[ #123 ]`). | ||
- Blocks commits with invalid messages. | ||
There is a [pre-push](/git-hooks/pre-push) hook that will run static analysis checks before any code is pushed up to the remote repository. This way, if you have any code smells, you can be alerted right away without waiting for the GitHub Actions to fail. | ||
--- | ||
## **Examples** | ||
### Valid Commit Messages: | ||
- `Fix login issue #123` | ||
- `[ #456 ] Refactor module` | ||
### Invalid Commit Messages: | ||
- `Fix login issue` _(No issue number)._ | ||
- `Updated README 123` _(Missing `#` prefix)._ | ||
## **Why These settings?** | ||
1. **Improving Traceability**: | ||
- The `commit-msg` hook enforces commit message standards, making it easier to link commits to specific issues. | ||
2. **Automating Hook Installation**: | ||
- Integrating hook installation with the `clean` task reduces manual steps and ensures hooks are always up-to-date. | ||
--- | ||
## **Directory Structure** | ||
```plaintext | ||
project-root/ | ||
├── .git/ | ||
│ ├── hooks/ | ||
│ ├── pre-commit | ||
│ ├── pre-push | ||
│ ├── commit-msg | ||
├── build.gradle.kts | ||
├── git-hooks/ | ||
│ ├── pre-commit-unix.sh | ||
│ ├── pre-commit-windows.sh | ||
│ ├── pre-push-unix.sh | ||
│ ├── pre-push-windows.sh | ||
│ ├── commit-msg-unix.sh | ||
│ ├── commit-msg-windows.sh |