Skip to content

Commit 5d5272e

Browse files
committed
fix: handle PR with empty body except for cc:
If the body of the PR description is deleted and gitgitgadget adds `cc` entries, it will add a couple of empty lines before the `cc`. This was not picked up and the `cc(s)` were sent as the description. Contributors manually adding a `cc` did not add the empty lines. The fix is to allow the description to have no content before the empty lines. Signed-off-by: Chris. Webster <chris@webstech.net>
1 parent 92f3662 commit 5d5272e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/patch-series.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export class PatchSeries {
208208
let rangeDiff: string | undefined;
209209

210210
// parse the footers of the pullRequestDescription
211-
let match = prBody.match(/^([^]+)\n\n([^]+)$/);
211+
let match = prBody.match(/^([^]*)\n\n([^]+)$/);
212212

213213
if (!match && !prBody.match(/\n\n/)) {
214214
// handle PR descriptions that have no body, just footers

tests/patch-series.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,15 @@ Fetch-It-Via: git fetch ${repoUrl} my-series-v1
496496

497497
expect(parsed.coverLetter).toEqual(expectedCover1);
498498

499+
// test with empty body and gitgitgadget added cc's
500+
const cc = "Some Person <shout@out.loud>";
501+
prBody = ["", "", `Cc: ${cc}`].join("\r\n");
502+
503+
parsed = await PatchSeries.parsePullRequest(repo.workDir, prTitle, prBody, 76, "");
504+
505+
expect(parsed.coverLetter.length).toEqual(prTitle.length);
506+
expect(parsed.cc).toEqual([cc]);
507+
499508
// Markdown-formatted Cc test (copy/pasted from GitHub)
500509
prBody = [
501510
"some description",

0 commit comments

Comments
 (0)