mirror of
https://github.com/wagoid/commitlint-github-action.git
synced 2025-11-07 16:06:56 +00:00
add excludeTargetBranch input option
This commit is contained in:
parent
481aff4de4
commit
b779028e6a
3 changed files with 22 additions and 1 deletions
|
|
@ -72,6 +72,12 @@ You can see more info about GitHub's default token [here](https://docs.github.co
|
||||||
|
|
||||||
default: `${{ github.token }}`
|
default: `${{ github.token }}`
|
||||||
|
|
||||||
|
### `excludeTargetBranch`
|
||||||
|
|
||||||
|
When set to `true` excludes commits from the target branch. This is useful if the two branches diverged at a time before `commitlint` was used. In this case, the target branch may have old commits that are not in the source branch and which don't follow the lint rules. In this case, they'll be flagged on every check and there's nothing you can do to resolve it. In this case, turn on `excludeTargetBranch`.
|
||||||
|
|
||||||
|
default: `false`
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
### `results`
|
### `results`
|
||||||
|
|
|
||||||
11
action.yml
11
action.yml
|
|
@ -34,6 +34,17 @@ inputs:
|
||||||
https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
required: false
|
required: false
|
||||||
|
excludeTargetBranch:
|
||||||
|
description: >
|
||||||
|
When set to `true` excludes commits from the target branch. This is useful on merge commits of two
|
||||||
|
divergent branches. By default all of the commits in the target branch that are not in the source
|
||||||
|
branch will be linted again. Set this to `true` to avoid that.
|
||||||
|
|
||||||
|
TODO: This explanation can be made better when I better understand why `--firstParent` alone didn't resolve this.
|
||||||
|
To do that I need to understand what `git log <revision range>` is doing.
|
||||||
|
default: "false"
|
||||||
|
required: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
results:
|
results:
|
||||||
description: The error and warning messages for each one of the analyzed commits
|
description: The error and warning messages for each one of the analyzed commits
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ const pullRequestEvent = 'pull_request'
|
||||||
const pullRequestTargetEvent = 'pull_request_target'
|
const pullRequestTargetEvent = 'pull_request_target'
|
||||||
const pullRequestEvents = [pullRequestEvent, pullRequestTargetEvent]
|
const pullRequestEvents = [pullRequestEvent, pullRequestTargetEvent]
|
||||||
|
|
||||||
const { GITHUB_EVENT_NAME, GITHUB_SHA } = process.env
|
const { GITHUB_EVENT_NAME, GITHUB_SHA, GITHUB_BASE_REF } = process.env
|
||||||
|
|
||||||
const configPath = resolve(process.env.GITHUB_WORKSPACE, getInput('configFile'))
|
const configPath = resolve(process.env.GITHUB_WORKSPACE, getInput('configFile'))
|
||||||
|
|
||||||
|
|
@ -78,6 +78,10 @@ function getHistoryCommits(from, to) {
|
||||||
options.firstParent = true
|
options.firstParent = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getInput('excludeTargetBranch') === 'true') {
|
||||||
|
options[`^${GITHUB_BASE_REF}`] = true
|
||||||
|
}
|
||||||
|
|
||||||
if (!from) {
|
if (!from) {
|
||||||
options.maxCount = 1
|
options.maxCount = 1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue