golangci-lint-action
golangci-lint-action copied to clipboard
fix: only-new-issues should return empty string for fetchPatch
fetchPatch
determines the patchPath
. If the patchPath
is not empty, the action explicitly overrides user input and sets --new-from-patch=<patch_path>
, --new=false
and --new-from-rev
to be empty. only-new-issues
should obviously set --new
to be true
.
Closes #531
Signed-off-by: Conor Evans [email protected]
This is in fetchPatch
. This is then used in prepareEnv
async function prepareEnv(): Promise<Env> {
// ...
const patchPromise = fetchPatch()
// ...
const patchPath = await patchPromise
// ....
return { lintPath, patchPath }
}
prepareEnv
is then used to get the arguments for runLint
- again we have patchPath
that should be returned as ""
when only-new-issues
is true.
export async function run(): Promise<void> {
// ...
const { lintPath, patchPath } = await core.group(`prepare environment`, prepareEnv)
// ...
await core.group(`run golangci-lint`, () => runLint(lintPath, patchPath))
In runLint
the patchPath
if set explicitly overrides the new arguments...
async function runLint(lintPath: string, patchPath: string): Promise<void> {
// ...
if (patchPath) {
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
throw new Error(`please, don't specify manually --new* args when requesting only new issues`)
}
addedArgs.push(`--new-from-patch=${patchPath}`)
// Override config values.
addedArgs.push(`--new=false`)
addedArgs.push(`--new-from-rev=`)
}
Pretty self explanatory fix all the same.
FYI @ldez @etiennem - Etienne for the moment if you simply set only-new-issues
to false
it will act as you think it would when you set true
.
Hi @ldez :wave:
Do you think it could be possible to have a look at this PR?
This PR will completely change the behavior:
- if
only-new-issues
istrue
: it will not generate and use the patch from GitHub - if
only-new-issues
isfalse
(the default): it will generate and use the patch from GitHub
This is not the expected behavior.
The assumptions of this PR are wrong.
-
only-new-issues
is only here to use the patch generated by GitHub. -
--new
is to check unstaged changes or untracked files or changes in HEAD~ -
only-new-issues
is not related to--new
https://golangci-lint.run/usage/configuration/#issues-configuration