Skip to content

Commit 776afad

Browse files
committed
Reformat for longer allowed line length
Reduce the number of lines split across multiple lines. Signed-off-by: Chris. Webster <chris@webstech.net>
1 parent 3d092fe commit 776afad

File tree

1 file changed

+30
-64
lines changed

1 file changed

+30
-64
lines changed

lib/mail-archive-helper.ts

Lines changed: 30 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,21 @@ import { GitHubGlue } from "./github-glue";
66
import { IMailMetadata } from "./mail-metadata";
77
import { IPatchSeriesMetadata } from "./patch-series-metadata";
88
import { IConfig, getConfig } from "./project-config";
9-
import { IParsedMBox, parseMBox,
10-
parseMBoxMessageIDAndReferences } from "./send-mail";
9+
import { IParsedMBox, parseMBox, parseMBoxMessageIDAndReferences } from "./send-mail";
1110
import { SousChef } from "./sous-chef";
1211

1312
export const stateKey = "git@vger.kernel.org <-> GitGitGadget";
14-
const replyToThisURL =
15-
"https://github.com/gitgitgadget/gitgitgadget/wiki/ReplyToThis";
13+
const replyToThisURL = "https://github.com/gitgitgadget/gitgitgadget/wiki/ReplyToThis";
1614

1715
export interface IGitMailingListMirrorState {
1816
latestRevision?: string;
1917
}
2018

2119
export class MailArchiveGitHelper {
22-
public static async get(gggNotes: GitNotes, mailArchiveGitDir: string,
23-
githubGlue: GitHubGlue, branch: string):
20+
public static async get(gggNotes: GitNotes, mailArchiveGitDir: string, githubGlue: GitHubGlue, branch: string):
2421
Promise<MailArchiveGitHelper> {
25-
const state: IGitMailingListMirrorState =
26-
await gggNotes.get<IGitMailingListMirrorState>(stateKey) || {};
27-
return new MailArchiveGitHelper(gggNotes, mailArchiveGitDir, githubGlue,
28-
state, branch);
22+
const state: IGitMailingListMirrorState = await gggNotes.get<IGitMailingListMirrorState>(stateKey) || {};
23+
return new MailArchiveGitHelper(gggNotes, mailArchiveGitDir, githubGlue, state, branch);
2924
}
3025

3126
/**
@@ -62,19 +57,16 @@ export class MailArchiveGitHelper {
6257
protected readonly mailArchiveGitDir: string;
6358
protected readonly githubGlue: GitHubGlue;
6459

65-
protected constructor(gggNotes: GitNotes, mailArchiveGitDir: string,
66-
githubGlue: GitHubGlue,
67-
state: IGitMailingListMirrorState,
68-
branch: string) {
60+
protected constructor(gggNotes: GitNotes, mailArchiveGitDir: string, githubGlue: GitHubGlue,
61+
state: IGitMailingListMirrorState, branch: string) {
6962
this.branch = branch;
7063
this.gggNotes = gggNotes;
7164
this.mailArchiveGitDir = mailArchiveGitDir;
7265
this.githubGlue = githubGlue;
7366
this.state = state;
7467
}
7568

76-
public async processMails(prFilter?: (pullRequestURL: string) => boolean):
77-
Promise<boolean> {
69+
public async processMails(prFilter?: (pullRequestURL: string) => boolean): Promise<boolean> {
7870
const keys: Set<string> = new Set<string>();
7971
(await git(["ls-tree", "-r", `${this.gggNotes.notesRef}:`],
8072
{ workDir: this.gggNotes.workDir })).split("\n")
@@ -99,11 +91,9 @@ export class MailArchiveGitHelper {
9991
if (prFilter && !prFilter(pullRequestURL)) {
10092
continue;
10193
}
102-
const prMeta = await this.gggNotes
103-
.get<IPatchSeriesMetadata>(pullRequestURL);
94+
const prMeta = await this.gggNotes.get<IPatchSeriesMetadata>(pullRequestURL);
10495
if (prMeta && prMeta.branchNameInGitsterGit) {
105-
branchNameMap.set(prMeta.branchNameInGitsterGit,
106-
pullRequestURL);
96+
branchNameMap.set(prMeta.branchNameInGitsterGit, pullRequestURL);
10797
}
10898
}
10999
const sousChef = new SousChef(mbox);
@@ -115,35 +105,21 @@ export class MailArchiveGitHelper {
115105
for (const branchName of sousChef.branches.keys()) {
116106
const pullRequestURL = branchNameMap.get(branchName);
117107
if (pullRequestURL) {
118-
const branchBaseURL
119-
= "https://github.com/gitgitgadget/git/commits/";
108+
const branchBaseURL = "https://github.com/gitgitgadget/git/commits/";
120109
const info = sousChef.branches.get(branchName);
121-
const pre = info?.text
122-
.replace(/&/g, "&amp;")
123-
.replace(/</g, "&lt;").replace(/>/g, "&gt;");
110+
const pre = info?.text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
124111
let comment: string;
125112
if (!pre || pre.trim() === "") {
126-
comment = `The branch [\`${
127-
branchName}\`](${
128-
branchBaseURL}${
129-
branchName}) was mentioned in the "${
130-
info?.sectionName
131-
}" section of the [status updates](${
132-
whatsCookingBaseURL}${
133-
sousChef.messageID}) on the Git mailing list.`;
113+
comment = `The branch [\`${branchName}\`](${branchBaseURL}${
114+
branchName}) was mentioned in the "${info?.sectionName}" section of the [status updates](${
115+
whatsCookingBaseURL}${sousChef.messageID}) on the Git mailing list.`;
134116
} else {
135-
comment = `There was a [status update](${
136-
whatsCookingBaseURL}${
137-
sousChef.messageID}) in the "${
138-
info?.sectionName}" section about the branch [\`${
139-
branchName}\`](${
140-
branchBaseURL}${
141-
branchName}) on the Git mailing list:\n\n<pre>\n${
142-
pre}\n</pre>`;
117+
comment = `There was a [status update](${whatsCookingBaseURL}${sousChef.messageID}) in the "${
118+
info?.sectionName}" section about the branch [\`${branchName}\`](${branchBaseURL}${
119+
branchName}) on the Git mailing list:\n\n<pre>\n${pre}\n</pre>`;
143120
}
144121
console.log(`\n${pullRequestURL}: ${comment}`);
145-
await this.githubGlue
146-
.addPRComment(pullRequestURL, comment);
122+
await this.githubGlue.addPRComment(pullRequestURL, comment);
147123
}
148124
}
149125
};
@@ -170,17 +146,14 @@ export class MailArchiveGitHelper {
170146
let originalCommit: string | undefined;
171147
let issueCommentId: number | undefined;
172148
for (const reference of parsed.references.filter(seen)) {
173-
const data =
174-
await this.gggNotes.get<IMailMetadata>(reference);
149+
const data = await this.gggNotes.get<IMailMetadata>(reference);
175150
if (data && data.pullRequestURL) {
176151
if (prFilter && !prFilter(data.pullRequestURL)) {
177152
continue;
178153
}
179154
/* Cover letters were recorded with their tip commits */
180-
const commit = reference.match(/^pull/) ?
181-
undefined : data.originalCommit;
182-
if (!pullRequestURL ||
183-
(!originalCommit && commit) ||
155+
const commit = reference.match(/^pull/) ? undefined : data.originalCommit;
156+
if (!pullRequestURL || (!originalCommit && commit) ||
184157
(!issueCommentId && data.issueCommentId)) {
185158
pullRequestURL = data.pullRequestURL;
186159
issueCommentId = data.issueCommentId;
@@ -198,21 +171,17 @@ export class MailArchiveGitHelper {
198171
}, comment ID: ${issueCommentId}`);
199172

200173
const archiveURL = `${this.config.mailrepo.url}${parsed.messageID}`;
201-
const header = `[On the Git mailing list](${archiveURL}), ` +
202-
(parsedMbox.from ?
203-
parsedMbox.from.replace(/ *<.*>/, "") : "Somebody") +
204-
` wrote ([reply to this](${replyToThisURL})):\n\n`;
174+
const header = `[On the Git mailing list](${archiveURL}), ${
175+
parsedMbox.from ? parsedMbox.from.replace(/ *<.*>/, "") : "Somebody"
176+
} wrote ([reply to this](${replyToThisURL})):\n\n`;
205177
const comment = MailArchiveGitHelper.mbox2markdown(parsedMbox);
206178
const fullComment = header + comment;
207179

208180
if (issueCommentId) {
209-
await this.githubGlue.addPRCommentReply(pullRequestURL,
210-
issueCommentId,
211-
fullComment);
181+
await this.githubGlue.addPRCommentReply(pullRequestURL, issueCommentId, fullComment);
212182
} else if (originalCommit) {
213183
try {
214-
const result = await this.githubGlue
215-
.addPRCommitComment(pullRequestURL, originalCommit,
184+
const result = await this.githubGlue.addPRCommitComment(pullRequestURL, originalCommit,
216185
this.gggNotes.workDir, fullComment);
217186
issueCommentId = result.id;
218187
} catch (error) {
@@ -225,12 +194,10 @@ export class MailArchiveGitHelper {
225194
* We will not use the ID of this comment, as it is an
226195
* issue comment, really, not a Pull Request comment.
227196
*/
228-
await this.githubGlue
229-
.addPRComment(pullRequestURL, fullComment);
197+
await this.githubGlue.addPRComment(pullRequestURL, fullComment);
230198
}
231199

232-
await this.githubGlue.addPRCc(pullRequestURL,
233-
parsedMbox.from || "");
200+
await this.githubGlue.addPRCc(pullRequestURL, parsedMbox.from || "");
234201

235202
await this.gggNotes.set(parsed.messageID, {
236203
issueCommentId,
@@ -281,8 +248,7 @@ export class MailArchiveGitHelper {
281248

282249
const range = `${this.state.latestRevision}..${head}`;
283250
console.log(`Handling commit range ${range}`);
284-
await git(["log", "-p", "-U99999", "--reverse", range],
285-
{ lineHandler, workDir: this.mailArchiveGitDir });
251+
await git(["log", "-p", "-U99999", "--reverse", range], { lineHandler, workDir: this.mailArchiveGitDir });
286252

287253
this.state.latestRevision = head;
288254
await this.gggNotes.set(stateKey, this.state, true);

0 commit comments

Comments
 (0)