Skip to content

Commit c1607ad

Browse files
committed
mail archive - catch comment errors
Email comments on specific commits (not 0 in series) fail if the first line is not part of the change. This is part of a couple of patches to get past this problem. Failed commit commenting will be a PR comment. First step to make sure comments are not missed. Signed-off-by: Chris. Webster <chris@webstech.net>
2 parents d66bbf6 + 17b7bbe commit c1607ad

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

lib/mail-archive-helper.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,31 @@ export class MailArchiveGitHelper {
202202
(parsedMbox.from ?
203203
parsedMbox.from.replace(/ *<.*>/, "") : "Somebody") +
204204
` wrote ([reply to this](${replyToThisURL})):\n\n`;
205-
const comment = header +
206-
MailArchiveGitHelper.mbox2markdown(parsedMbox);
205+
const comment = MailArchiveGitHelper.mbox2markdown(parsedMbox);
206+
const fullComment = header + comment;
207207

208208
if (issueCommentId) {
209209
await this.githubGlue.addPRCommentReply(pullRequestURL,
210210
issueCommentId,
211-
comment);
211+
fullComment);
212212
} else if (originalCommit) {
213-
const result = await this.githubGlue
214-
.addPRCommitComment(pullRequestURL, originalCommit,
215-
this.gggNotes.workDir, comment);
216-
issueCommentId = result.id;
213+
try {
214+
const result = await this.githubGlue
215+
.addPRCommitComment(pullRequestURL, originalCommit,
216+
this.gggNotes.workDir, fullComment);
217+
issueCommentId = result.id;
218+
} catch (error) {
219+
const regarding = `${header.slice(0,-3)}, regarding ${originalCommit}:\n\n`;
220+
await this.githubGlue.addPRComment(pullRequestURL, regarding + comment);
221+
originalCommit = undefined;
222+
}
217223
} else {
218224
/*
219225
* We will not use the ID of this comment, as it is an
220226
* issue comment, really, not a Pull Request comment.
221227
*/
222228
await this.githubGlue
223-
.addPRComment(pullRequestURL, comment);
229+
.addPRComment(pullRequestURL, fullComment);
224230
}
225231

226232
await this.githubGlue.addPRCc(pullRequestURL,

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@types/jsonwebtoken": "^8.5.9",
4646
"@types/mailparser": "^3.4.0",
4747
"@types/marked": "^4.0.8",
48-
"@types/nodemailer": "^6.4.6",
48+
"@types/nodemailer": "^6.4.7",
4949
"@types/rfc2047": "^2.0.1",
5050
"@typescript-eslint/eslint-plugin": "^5.46.1",
5151
"@typescript-eslint/parser": "^5.46.1",

0 commit comments

Comments
 (0)