-
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 #6 from AppDifferentia/update-document
[Doc] Update documentation
- Loading branch information
Showing
23 changed files
with
131 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,77 @@ | ||
# danger-swift-commit-lint | ||
A Danger-Swift plugin to check commit messages | ||
# Commit Lint For Danger-Swift | ||
|
||
A [`danger-swift`]("https://github.com/danger/swift") plugin to check each commit messages on the branch. This project is inspired by [`danger-commit-lint`](https://github.com/jonallured/danger-commit_lint) and its commit linting rules are ported too. | ||
|
||
## Installation | ||
|
||
Add `DangerSwiftCommitLint` to your `Package.file` | ||
```Swift | ||
.package(url: "https://github.com/AppDifferentia/danger-swift-commit-lint", from: "0.0.1") | ||
``` | ||
|
||
## Usage | ||
|
||
Simply add the following lines to your `Dangerfile.swift` | ||
|
||
```Swift | ||
import Danger | ||
|
||
let danger = Danger() | ||
|
||
//... | ||
|
||
let commitLint = DangerSwiftCommitLint(danger: danger) | ||
commitLint.check() | ||
``` | ||
|
||
That will check each commit in the PR to ensure the following is true: | ||
|
||
- Commit subject begins with a capital letter (`Sources/DangerSwiftLint/CommitLint/SubjectCapitalLetter`) | ||
- Commit subject is more than one word (`Sources/DangerSwiftLint/CommitLint/SubjectWord`) | ||
- Commit subject is no longer than 50 characters (`Sources/DangerSwiftLint/CommitLint/SubjectLength`) | ||
- Commit subject does not end in a period (`Sources/DangerSwiftLint/CommitLint/SubjectPeriod`) | ||
- Commit subject and body are separated by an empty line (`Sources/DangerSwiftLint/CommitLint/BodyEmptyLine`) | ||
|
||
By default, Commit Lint fails, but you can configure this behavior. | ||
|
||
E.g. | ||
|
||
```Swift | ||
import Danger | ||
|
||
let danger = Danger() | ||
|
||
//... | ||
|
||
let configuration = DangerSwiftCommitLint.Configuration(warn: .all) | ||
let commitLint = DangerSwiftCommitLint(danger: danger, configuration: configuration) | ||
commitLint.check() | ||
``` | ||
|
||
## Configuration | ||
|
||
The commit lint can be configured with following 5 parameters. | ||
|
||
- `disabled`: can be `.all` or `.selected([ ... ])`, see [`DangerSwiftCommitLint/Configuration`]("DangerSwiftCommitLint/Configuration") | ||
- `warn`: can be `.all` or `.selected([ ... ])`, see [`DangerSwiftCommitLint/Configuration`]("DangerSwiftCommitLint/Configuration") | ||
- `fail`: can be `.all` or `.selected([ ... ])`, see [`DangerSwiftCommitLint/Configuration`]("DangerSwiftCommitLint/Configuration") | ||
- `limit`: limits the number commits to lint. E.g. `limit: 1` will limit the commit to the oldest commit on the branch | ||
- `custom`: allow caller to pass an array of custom linter that conforms to `DangerSwiftCommitLint.CommitLint` protocol | ||
|
||
E.g. | ||
|
||
```Swift | ||
struct Configuration { | ||
|
||
init( | ||
disabled: CommitLintSelection = .selected([]), | ||
warn: CommitLintSelection = .selected([]), | ||
fail: CommitLintSelection = .all, | ||
limit: Int = 0, | ||
custom: [CommitLint.Type] = [] | ||
) { | ||
// ... | ||
} | ||
|
||
} | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../CommitChecker/SubjectCapCheckTests.swift → ...ommitLint/SubjectCapitalLetterTests.swift
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
2 changes: 1 addition & 1 deletion
2
...mmitChecker/SubjectLengthCheckTests.swift → ...Tests/CommitLint/SubjectLengthTests.swift
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
2 changes: 1 addition & 1 deletion
2
...mmitChecker/SubjectPeriodCheckTests.swift → ...Tests/CommitLint/SubjectPeriodTests.swift
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
2 changes: 1 addition & 1 deletion
2
...CommitChecker/SubjectWorkCheckTests.swift → ...ts/CommitLint/SubjectWorkCheckTests.swift
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
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