Skip to content

Commit 772b5c9

Browse files
committed
misc-helper: address white-space issues pointed out by ESLint
Signed-off-by: Johannes Schindelin <[email protected]>
1 parent cd66607 commit 772b5c9

File tree

1 file changed

+52
-37
lines changed

1 file changed

+52
-37
lines changed

script/misc-helper.ts

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@ import path from "path";
1616
const commander = new Command();
1717
const publishRemoteKey = "publishRemote";
1818

19-
commander.version("1.0.0")
19+
commander
20+
.version("1.0.0")
2021
.usage("[options] ( update-open-prs | lookup-upstream-commit | annotate-commit <pr-number> <original> <git.git> )")
2122
.description("Command-line helper for GitGitGadget")
22-
.option("-g, --git-work-dir [directory]",
23-
"Use a different git.git working directory than specified via `gitgitgadget.workDir`", undefined)
24-
.option("-G, --gitgitgadget-work-dir [directory]",
25-
"Use a different gitgitgadget working directory than the current working directory to access the Git "
26-
+ "config e.g. for `gitgitgadget.workDir`", ".")
23+
.option(
24+
"-g, --git-work-dir [directory]",
25+
"Use a different git.git working directory than specified via `gitgitgadget.workDir`",
26+
undefined,
27+
)
28+
.option(
29+
"-G, --gitgitgadget-work-dir [directory]",
30+
"Use a different gitgitgadget working directory than the current working directory to access the Git config" +
31+
"e.g. for `gitgitgadget.workDir`",
32+
".",
33+
)
2734
.option("-c, --config <string>", "Use this configuration when using gitgitgadget with a project other than git", "")
2835
.option("-s, --skip-update", "Do not update the local refs (useful for debugging)")
2936
.parse(process.argv);
@@ -42,7 +49,8 @@ if (commander.args.length === 0) {
4249
const commandOptions = commander.opts<ICommanderOptions>();
4350

4451
(async (): Promise<void> => {
45-
const config: IConfig = commandOptions.config ? setConfig(await getExternalConfig(commandOptions.config))
52+
const config: IConfig = commandOptions.config
53+
? setConfig(await getExternalConfig(commandOptions.config))
4654
: getConfig();
4755

4856
const getGitGitWorkDir = async (): Promise<string> => {
@@ -115,8 +123,11 @@ const commandOptions = commander.opts<ICommanderOptions>();
115123
await ci.setUpstreamCommit(originalCommit, gitGitCommit);
116124
} else if (command === "set-tip-commit-in-git.git") {
117125
if (commander.args.length !== 3) {
118-
process.stderr.write(`${command}: needs 2 parameters:\nPR URL and tip commit in ${
119-
config.repo.baseOwner}.${config.repo.name}`);
126+
process.stderr.write(
127+
`${command}: needs 2 parameters:\nPR URL and tip commit in ${
128+
config.repo.baseOwner
129+
}.${config.repo.name}`,
130+
);
120131
process.exit(1);
121132
}
122133
const pullRequestURL = commander.args[1];
@@ -130,8 +141,10 @@ const commandOptions = commander.opts<ICommanderOptions>();
130141
await ci.notes.set(pullRequestURL, data, true);
131142
} else if (command === "set-previous-iteration") {
132143
if (commander.args.length !== 9) {
133-
process.stderr.write(`${command}: needs PR URL, iteration, cover-letter Message ID, latest tag, ${
134-
""}base commit, base label, head commit, head label\n`);
144+
process.stderr.write(
145+
`${command}: needs PR URL, iteration, cover-letter Message ID, latest tag, ` +
146+
"base commit, base label, head commit, head label\n",
147+
);
135148
process.exit(1);
136149
}
137150
const pullRequestURL = commander.args[1];
@@ -172,8 +185,9 @@ const commandOptions = commander.opts<ICommanderOptions>();
172185
console.log(`Result: ${result}`);
173186
} else if (command === "annotate-commit") {
174187
if (commander.args.length !== 3) {
175-
process.stderr.write(`${command}: needs 2 parameters: original and ${
176-
config.repo.baseOwner}.${config.repo.name} commit\n`);
188+
process.stderr.write(
189+
`${command}: needs 2 parameters: original and ${config.repo.baseOwner}.${config.repo.name} commit\n`,
190+
);
177191
process.exit(1);
178192
}
179193

@@ -211,16 +225,17 @@ const commandOptions = commander.opts<ICommanderOptions>();
211225
process.stderr.write(`${command}: ${config.repo.owner}/${config.repo.name} already initialized\n`);
212226
process.exit(1);
213227
} catch (_error) {
214-
const options: IGitGitGadgetOptions = { allowedUsers: [ commander.args[1] ] };
228+
const options: IGitGitGadgetOptions = { allowedUsers: [commander.args[1]] };
215229
await ci.notes.set("", options, true);
216230

217231
const publishTagsAndNotesToRemote = await getVar(publishRemoteKey, commandOptions.gitgitgadgetWorkDir);
218232

219233
if (!publishTagsAndNotesToRemote) {
220234
throw new Error("No remote to which to push configured");
221235
}
222-
await git(["push", publishTagsAndNotesToRemote, "--", `${ci.notes.notesRef}`],
223-
{ workDir: commandOptions.gitWorkDir });
236+
await git(["push", publishTagsAndNotesToRemote, "--", `${ci.notes.notesRef}`], {
237+
workDir: commandOptions.gitWorkDir,
238+
});
224239
}
225240

226241
console.log(toPrettyJSON(await ci.getGitGitGadgetOptions()));
@@ -243,8 +258,9 @@ const commandOptions = commander.opts<ICommanderOptions>();
243258
if (!publishTagsAndNotesToRemote) {
244259
throw new Error("No remote to which to push configured");
245260
}
246-
await git(["push", publishTagsAndNotesToRemote, "--", `${ci.notes.notesRef}`],
247-
{ workDir: commandOptions.gitWorkDir });
261+
await git(["push", publishTagsAndNotesToRemote, "--", `${ci.notes.notesRef}`], {
262+
workDir: commandOptions.gitWorkDir,
263+
});
248264

249265
console.log(toPrettyJSON(state));
250266
} else if (command === "get-mail-meta") {
@@ -263,8 +279,9 @@ const commandOptions = commander.opts<ICommanderOptions>();
263279
const repositoryOwner = commander.args.length === 3 ? commander.args[1] : config.repo.owner;
264280
const prNumber = commander.args[commander.args.length === 3 ? 2 : 1];
265281

266-
const pullRequestURL = prNumber.match(/^http/) ? prNumber :
267-
`https://github.com/${repositoryOwner}/${config.repo.name}/pull/${prNumber}`;
282+
const pullRequestURL = prNumber.match(/^http/)
283+
? prNumber
284+
: `https://github.com/${repositoryOwner}/${config.repo.name}/pull/${prNumber}`;
268285
console.log(toPrettyJSON(await ci.getPRMetadata(pullRequestURL)));
269286
} else if (command === "get-pr-commits") {
270287
if (commander.args.length !== 2 && commander.args.length !== 3) {
@@ -317,8 +334,7 @@ const commandOptions = commander.opts<ICommanderOptions>();
317334
if (meta.baseCommit && meta.headCommit) {
318335
for (const rev of await ci.getOriginalCommitsForPR(meta)) {
319336
const messageID = await ci.notes.getLastCommitNote(rev);
320-
if (messageID &&
321-
options.activeMessageIDs[messageID] === undefined) {
337+
if (messageID && options.activeMessageIDs[messageID] === undefined) {
322338
options.activeMessageIDs[messageID] = rev;
323339
optionsUpdated = true;
324340
if (await ci.updateCommitMapping(messageID)) {
@@ -342,19 +358,15 @@ const commandOptions = commander.opts<ICommanderOptions>();
342358
process.stderr.write(`${command}: need a PR URL and a comment\n`);
343359
process.exit(1);
344360
}
345-
const pullRequestURL = commander.args[1].match(/^[0-9]+$/) ?
346-
`https://github.com/gitgitgadget/${config.repo.name}/pull/${commander.args[1]}` :
347-
commander.args[1];
361+
const pullRequestURL = commander.args[1].match(/^[0-9]+$/)
362+
? `https://github.com/gitgitgadget/${config.repo.name}/pull/${commander.args[1]}`
363+
: commander.args[1];
348364
const comment = commander.args[2];
349365

350366
const glue = new GitHubGlue(ci.workDir, config.repo.owner, config.repo.name);
351367
await glue.addPRComment(pullRequestURL, comment);
352368
} else if (command === "set-app-token") {
353-
const set = async (options: {
354-
appID: number;
355-
installationID?: number;
356-
name: string;
357-
}): Promise<void> => {
369+
const set = async (options: { appID: number; installationID?: number; name: string }): Promise<void> => {
358370
const appName = options.name === config.app.name ? config.app.name : config.app.altname;
359371
const appNameKey = `${appName}.privateKey`;
360372
const appNameVar = appNameKey.toUpperCase().replace(/\./, "_");
@@ -368,21 +380,24 @@ const commandOptions = commander.opts<ICommanderOptions>();
368380
authStrategy: createAppAuth,
369381
auth: {
370382
appId: options.appID,
371-
privateKey: key.replace(/\\n/g, `\n`)
383+
privateKey: key.replace(/\\n/g, `\n`),
372384
},
373385
});
374386

375387
if (options.installationID === undefined) {
376-
options.installationID =
377-
(await client.rest.apps.getRepoInstallation({
388+
options.installationID = (
389+
await client.rest.apps.getRepoInstallation({
378390
owner: options.name,
379391
repo: config.repo.name,
380-
})).data.id;
392+
})
393+
).data.id;
381394
}
382-
const result = await client.rest.apps.createInstallationAccessToken( {
395+
const result = await client.rest.apps.createInstallationAccessToken({
383396
installation_id: options.installationID,
384-
});
385-
const configKey = options.name === config.app.name ? `${config.app.name}.githubToken`
397+
});
398+
const configKey =
399+
options.name === config.app.name
400+
? `${config.app.name}.githubToken`
386401
: `gitgitgadget.${options.name}.githubToken`;
387402
await git(["config", configKey, result.data.token]);
388403
};

0 commit comments

Comments
 (0)