fix: preserve new lines in body and comments (#72)

This commit is contained in:
Andrea Lamparelli 2023-07-27 15:35:23 +02:00 committed by GitHub
parent a402fa4525
commit fa43ffc1dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 38 deletions

7
dist/cli/index.js vendored
View file

@ -340,7 +340,7 @@ class PullRequestConfigsParser extends configs_parser_1.default {
}
}
const bodyPrefix = args.bodyPrefix ?? `**Backport:** ${originalPullRequest.htmlUrl}\r\n\r\n`;
const body = args.body ?? `${originalPullRequest.body}`;
const body = bodyPrefix + (args.body ?? `${originalPullRequest.body}`);
const labels = args.labels ?? [];
if (args.inheritLabels) {
labels.push(...originalPullRequest.labels);
@ -361,11 +361,12 @@ class PullRequestConfigsParser extends configs_parser_1.default {
head: backportBranch,
base: args.targetBranch,
title: args.title ?? `[${args.targetBranch}] ${originalPullRequest.title}`,
body: `${bodyPrefix}${body}`,
// preserve new line chars
body: body.replace(/\\n/g, "\n").replace(/\\r/g, "\r"),
reviewers: [...new Set(reviewers)],
assignees: [...new Set(args.assignees)],
labels: [...new Set(labels)],
comments: args.comments ?? [],
comments: args.comments?.map(c => c.replace(/\\n/g, "\n").replace(/\\r/g, "\r")) ?? [],
};
}
}