diff --git a/README.md b/README.md index cfad640..406e2ee 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,15 @@ jobs: The path to your commitlint config file. Default `commitlint.config.js`. +### `firstParent` + +When set to true, we follow only the first parent commit when seeing a merge commit. + +This helps to ignore errors in commits that were already present in your default branch (e.g. `master`) before adding conventional commit checks. +More info in [git-log docs](https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent). + +Default `true` + ## About `extends` in your config file This is a [`Docker` action](https://github.com/actions/toolkit/blob/e2adf403d6d14a9ca7474976ccaca20f72ff8209/docs/action-types.md#why-would-i-choose-a-docker-action), and was made like this so that you can run it with minimum setup, regardless of your repo's environment. It comes packed with the most famous shared configurations that you can use in your commitlint config's `extends` field: diff --git a/action.yml b/action.yml index edfba44..90d2d10 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,9 @@ inputs: configFile: description: 'commitlint config file' default: './commitlint.config.js' + firstParent: + description: 'when set to true, we follow only the first parent commit when seeing a merge commit. More info in git-log docs https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent' + default: true runs: using: 'docker' image: 'docker://wagoid/commitlint-github-action:1.1.1' diff --git a/run.js b/run.js index 4573bb7..885786b 100644 --- a/run.js +++ b/run.js @@ -40,6 +40,10 @@ function getHistoryCommits(from, to) { to, } + if (core.getInput('firstParent') === 'true') { + options.firstParent = true + } + if (!from) { options.maxCount = 1 }