golangci-lint-action icon indicating copy to clipboard operation
golangci-lint-action copied to clipboard

fix: only-new-issues should return empty string for fetchPatch

Open conorevans opened this issue 2 years ago • 2 comments

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.

conorevans avatar Nov 11 '22 22:11 conorevans

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.

conorevans avatar Nov 11 '22 22:11 conorevans

Hi @ldez :wave:

Do you think it could be possible to have a look at this PR?

EtienneM avatar Feb 24 '23 07:02 EtienneM

This PR will completely change the behavior:

  • if only-new-issues is true: it will not generate and use the patch from GitHub
  • if only-new-issues is false (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

ldez avatar Apr 27 '24 00:04 ldez