From bd13a3ec665b04d1ad56d27dc8bf7402849dc71b Mon Sep 17 00:00:00 2001 From: Michael Welch Date: Thu, 26 Jan 2023 16:03:07 -0600 Subject: [PATCH] add excludeTarget input option --- README.md | 6 ++++++ action.yml | 8 ++++++++ src/action.js | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 1aa3e9e..bf210d7 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,12 @@ You can see more info about GitHub's default token [here](https://docs.github.co default: `${{ github.token }}` +### `excludeTarget` + +When set to `true` excludes commits from the target branch. + +default: `false` + ## Outputs ### `results` diff --git a/action.yml b/action.yml index ac999f6..e3b2847 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,14 @@ inputs: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token default: ${{ github.token }} required: false + excludeTarget: + 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. + default: "false" + required: false + outputs: results: description: The error and warning messages for each one of the analyzed commits diff --git a/src/action.js b/src/action.js index 8d34009..0a26bab 100644 --- a/src/action.js +++ b/src/action.js @@ -78,6 +78,10 @@ function getHistoryCommits(from, to) { options.firstParent = true } + if (getInput('excludeTarget') === 'true') { + options[`^${to}`] = true + } + if (!from) { options.maxCount = 1 }