Skip to content

Commit 322510a

Browse files
jrehwaldtldez
andauthored
feat: support out-format as args (#769)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent 185e7a2 commit 322510a

File tree

3 files changed

+48
-26
lines changed

3 files changed

+48
-26
lines changed

Diff for: dist/post_run/index.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -66639,16 +66639,23 @@ function runLint(lintPath, patchPath) {
6663966639
}
6664066640
const userArgs = core.getInput(`args`);
6664166641
const addedArgs = [];
66642-
const userArgNames = new Set(userArgs
66642+
const userArgsList = userArgs
6664366643
.trim()
6664466644
.split(/\s+/)
66645-
.map((arg) => arg.split(`=`)[0])
6664666645
.filter((arg) => arg.startsWith(`-`))
66647-
.map((arg) => arg.replace(/^-+/, ``)));
66648-
if (userArgNames.has(`out-format`)) {
66649-
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
66650-
}
66651-
addedArgs.push(`--out-format=github-actions`);
66646+
.map((arg) => arg.replace(/^-+/, ``))
66647+
.map((arg) => arg.split(/=(.*)/, 2))
66648+
.map(([key, value]) => [key.toLowerCase(), value !== null && value !== void 0 ? value : ""]);
66649+
const userArgsMap = new Map(userArgsList);
66650+
const userArgNames = new Set(userArgsList.map(([key]) => key));
66651+
const formats = (userArgsMap.get("out-format") || "")
66652+
.trim()
66653+
.split(",")
66654+
.filter((f) => f.length > 0)
66655+
.filter((f) => !f.startsWith(`github-actions`))
66656+
.concat("github-actions")
66657+
.join(",");
66658+
addedArgs.push(`--out-format=${formats}`);
6665266659
if (patchPath) {
6665366660
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
6665466661
throw new Error(`please, don't specify manually --new* args when requesting only new issues`);

Diff for: dist/run/index.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -66639,16 +66639,23 @@ function runLint(lintPath, patchPath) {
6663966639
}
6664066640
const userArgs = core.getInput(`args`);
6664166641
const addedArgs = [];
66642-
const userArgNames = new Set(userArgs
66642+
const userArgsList = userArgs
6664366643
.trim()
6664466644
.split(/\s+/)
66645-
.map((arg) => arg.split(`=`)[0])
6664666645
.filter((arg) => arg.startsWith(`-`))
66647-
.map((arg) => arg.replace(/^-+/, ``)));
66648-
if (userArgNames.has(`out-format`)) {
66649-
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
66650-
}
66651-
addedArgs.push(`--out-format=github-actions`);
66646+
.map((arg) => arg.replace(/^-+/, ``))
66647+
.map((arg) => arg.split(/=(.*)/, 2))
66648+
.map(([key, value]) => [key.toLowerCase(), value !== null && value !== void 0 ? value : ""]);
66649+
const userArgsMap = new Map(userArgsList);
66650+
const userArgNames = new Set(userArgsList.map(([key]) => key));
66651+
const formats = (userArgsMap.get("out-format") || "")
66652+
.trim()
66653+
.split(",")
66654+
.filter((f) => f.length > 0)
66655+
.filter((f) => !f.startsWith(`github-actions`))
66656+
.concat("github-actions")
66657+
.join(",");
66658+
addedArgs.push(`--out-format=${formats}`);
6665266659
if (patchPath) {
6665366660
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
6665466661
throw new Error(`please, don't specify manually --new* args when requesting only new issues`);

Diff for: src/run.ts

+20-12
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,26 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
121121
const userArgs = core.getInput(`args`)
122122
const addedArgs: string[] = []
123123

124-
const userArgNames = new Set<string>(
125-
userArgs
126-
.trim()
127-
.split(/\s+/)
128-
.map((arg) => arg.split(`=`)[0])
129-
.filter((arg) => arg.startsWith(`-`))
130-
.map((arg) => arg.replace(/^-+/, ``))
131-
)
132-
if (userArgNames.has(`out-format`)) {
133-
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
134-
}
135-
addedArgs.push(`--out-format=github-actions`)
124+
const userArgsList = userArgs
125+
.trim()
126+
.split(/\s+/)
127+
.filter((arg) => arg.startsWith(`-`))
128+
.map((arg) => arg.replace(/^-+/, ``))
129+
.map((arg) => arg.split(/=(.*)/, 2))
130+
.map<[string, string]>(([key, value]) => [key.toLowerCase(), value ?? ""])
131+
132+
const userArgsMap = new Map<string, string>(userArgsList)
133+
const userArgNames = new Set<string>(userArgsList.map(([key]) => key))
134+
135+
const formats = (userArgsMap.get("out-format") || "")
136+
.trim()
137+
.split(",")
138+
.filter((f) => f.length > 0)
139+
.filter((f) => !f.startsWith(`github-actions`))
140+
.concat("github-actions")
141+
.join(",")
142+
143+
addedArgs.push(`--out-format=${formats}`)
136144

137145
if (patchPath) {
138146
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {

0 commit comments

Comments
 (0)