fix(golangci): detect major version and use correct output flag for v2#597
fix(golangci): detect major version and use correct output flag for v2#597bnema wants to merge 1 commit intortk-ai:developfrom
Conversation
183ddc3 to
ee04933
Compare
golangci-lint v2 removed the --out-format flag. The wrapper now runs golangci-lint version, parses the major version, and injects --output.json.path=stdout for v2 or --out-format=json for v1. The user-supplied flag detection is also updated to recognise both v1 and v2 output flags. Closes rtk-ai#596 Signed-off-by: brice <b@bnema.dev>
|
Hello bnema ! Thanks for contributing , PR #612 also fix this, we need to review both to know which one to take for this fix. |
|
After reviewing both this PR and #612 side-by-side, i'm in favor of #612 as the base for this fix because it addresses several additional issues that could cause problems:
That said, your v prefix handling (trim_start_matches('v')) is something #612 is missing and would need to adopt, we've flagged that there. Your work directly contributed to catching that gap. |
Summary
The golangci-lint wrapper injects
--out-format=jsonto get structured output, but this flag was removed in golangci-lint v2. The wrapper now detects the installed major version and injects the correct flag.What changed
The wrapper runs
golangci-lint versionbefore the actual lint invocation, parses the major version from the output, and selects the appropriate flag:--output.json.path=stdout--out-format=json(existing behavior)The user-supplied flag detection was also updated to recognise both v1 and v2 output flags, so the wrapper does not override them.
The version parsing logic is extracted into its own function with unit tests covering v1 output, v2 output, empty input, and garbage input. Three additional tests cover the flag detection for v1 flags, v2 flags, and no flags.
Related
Closes #596
References
--out-formatremovalruncommand flags