Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support out-format as args #769

Merged
merged 3 commits into from Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions dist/post_run/index.js
Expand Up @@ -66575,16 +66575,23 @@ function runLint(lintPath, patchPath) {
}
const userArgs = core.getInput(`args`);
const addedArgs = [];
const userArgNames = new Set(userArgs
const userArgsList = userArgs
.trim()
.split(/\s+/)
.map((arg) => arg.split(`=`)[0])
.filter((arg) => arg.startsWith(`-`))
.map((arg) => arg.replace(/^-+/, ``)));
if (userArgNames.has(`out-format`)) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
}
addedArgs.push(`--out-format=github-actions`);
.map((arg) => arg.replace(/^-+/, ``))
.map((arg) => arg.split(/=(.*)/, 2))
.map(([key, value]) => [key.toLowerCase(), value !== null && value !== void 0 ? value : ""]);
const userArgsMap = new Map(userArgsList);
const userArgNames = new Set(userArgsList.map(([key]) => key));
const formats = (userArgsMap.get("out-format") || "")
.trim()
.split(",")
.filter((f) => f.length > 0)
.filter((f) => !f.startsWith(`github-actions`))
.concat("github-actions")
.join(",");
addedArgs.push(`--out-format=${formats}`);
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`);
Expand Down
21 changes: 14 additions & 7 deletions dist/run/index.js
Expand Up @@ -66575,16 +66575,23 @@ function runLint(lintPath, patchPath) {
}
const userArgs = core.getInput(`args`);
const addedArgs = [];
const userArgNames = new Set(userArgs
const userArgsList = userArgs
.trim()
.split(/\s+/)
.map((arg) => arg.split(`=`)[0])
.filter((arg) => arg.startsWith(`-`))
.map((arg) => arg.replace(/^-+/, ``)));
if (userArgNames.has(`out-format`)) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
}
addedArgs.push(`--out-format=github-actions`);
.map((arg) => arg.replace(/^-+/, ``))
.map((arg) => arg.split(/=(.*)/, 2))
.map(([key, value]) => [key.toLowerCase(), value !== null && value !== void 0 ? value : ""]);
const userArgsMap = new Map(userArgsList);
const userArgNames = new Set(userArgsList.map(([key]) => key));
const formats = (userArgsMap.get("out-format") || "")
.trim()
.split(",")
.filter((f) => f.length > 0)
.filter((f) => !f.startsWith(`github-actions`))
.concat("github-actions")
.join(",");
addedArgs.push(`--out-format=${formats}`);
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`);
Expand Down
32 changes: 20 additions & 12 deletions src/run.ts
Expand Up @@ -119,18 +119,26 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
const userArgs = core.getInput(`args`)
const addedArgs: string[] = []

const userArgNames = new Set<string>(
userArgs
.trim()
.split(/\s+/)
.map((arg) => arg.split(`=`)[0])
.filter((arg) => arg.startsWith(`-`))
.map((arg) => arg.replace(/^-+/, ``))
)
if (userArgNames.has(`out-format`)) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
}
addedArgs.push(`--out-format=github-actions`)
const userArgsList = userArgs
.trim()
.split(/\s+/)
.filter((arg) => arg.startsWith(`-`))
.map((arg) => arg.replace(/^-+/, ``))
.map((arg) => arg.split(/=(.*)/, 2))
.map<[string, string]>(([key, value]) => [key.toLowerCase(), value ?? ""])

const userArgsMap = new Map<string, string>(userArgsList)
const userArgNames = new Set<string>(userArgsList.map(([key]) => key))

const formats = (userArgsMap.get("out-format") || "")
.trim()
.split(",")
.filter((f) => f.length > 0)
.filter((f) => !f.startsWith(`github-actions`))
.concat("github-actions")
.join(",")

addedArgs.push(`--out-format=${formats}`)

if (patchPath) {
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {
Expand Down