Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AckeeCZ/danger-kotlin-commit-lint
Danger Kotlin Plugin for linting commit messages in PRs/MRs
https://github.com/AckeeCZ/danger-kotlin-commit-lint
commitlint danger danger-kotlin gitmoji kotlin
Last synced: about 1 month ago
JSON representation
Danger Kotlin Plugin for linting commit messages in PRs/MRs
- Host: GitHub
- URL: https://github.com/AckeeCZ/danger-kotlin-commit-lint
- Owner: AckeeCZ
- License: apache-2.0
- Created: 2020-07-02T10:32:21.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-20T05:45:33.000Z (almost 4 years ago)
- Last Synced: 2024-08-03T14:07:45.212Z (5 months ago)
- Topics: commitlint, danger, danger-kotlin, gitmoji, kotlin
- Language: Kotlin
- Homepage:
- Size: 78.1 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-danger - danger-kotlin-commit-lint - Lint the commit messages (Plugins / Kotlin (danger-kotlin))
README
[ ![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.ackeecz/danger-kotlin-commit-lint/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.ackeecz/danger-kotlin-commit-lint)
# danger-kotlin commit lint plugin
This is a plugin for [danger-kotlin](https://github.com/danger/kotlin) that checks if commit messages align with
recommendations specified eg. [here](https://chris.beams.io/posts/git-commit/)## Installation
Put
```kotlin
@file:DependsOn("io.github.ackeecz:danger-kotlin-commit-lint:x.y.z")
```to the top of your Dangerfile
## Usage
There is a single method `CommitLintPlugin.check` that will perform validations on the commits.
Due to a design of danger-kotlin plugin SDK it does not have access to commits directly and for that reason you need to
pass messages to the plugin manually.```kotlin
register CommitLintPlugindanger(args) {
CommitLintPlugin.check(commits = git.commits.map { gitCommit ->
Commit(CommitMessage.fromRawMessage(gitCommit.message), gitCommit.sha ?: "")
})
}
```### Rules specification
You can enable only some rules by passing them to the `check` function. By default, there are these rules:
| Name | Description
|------|------------|
| SUBJECT_LENGTH | Length of the subject is less than 50 characters |
| BODY_LENGTH | Length of the body is less than 72 characters |
| SUBJECT_BODY_NEW_LINE | Subject and body is separated with newline |
| SUBJECT_CAPITALIZE | Subject should start with capital letter |
| SUBJECT_MULTIPLE_WORDS | Subject have more than one word |
| SUBJECT_ENDS_WITH_PERIOD | Subject does not ends with a period |If you want to disable some rules you can do
```kotlin
CommitLintPlugin.check(commits, Rule.values().toList() - Rule.SUBJECT_CAPITALIZE)
```### GitMoji first
[GitMoji](https://gitmoji.carloscuesta.me/) characters are skipped in the beginning for `SUBJECT_CAPITALIZE`
and `SUBJECT_MULTIPLE_WORDS` rules.