Skip to content

Commit

Permalink
Merge pull request #188 from zeebe-io/fix-empty-body
Browse files Browse the repository at this point in the history
Support backporting pull requests with empty description (i.e. body)
  • Loading branch information
korthout authored Dec 24, 2021
2 parents 3e2f501 + f74bd64 commit 791c35e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class Github implements GithubApi {
export type PullRequest = {
number: number;
title: string;
body: string;
body: string | null;
head: {
sha: string;
};
Expand Down
4 changes: 4 additions & 0 deletions src/test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { getMentionedIssueRefs, composeBody } from "../utils";

describe("get mentioned issues", () => {
describe("returns an empty list", () => {
it("for an null text", () => {
expect(getMentionedIssueRefs(null)).toHaveLength(0);
});

it("for an empty text", () => {
expect(getMentionedIssueRefs("")).toHaveLength(0);
});
Expand Down
8 changes: 4 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function composeBody(

type PullRequest = {
number: number;
body: string;
body: string | null;
user: {
login: string;
};
Expand All @@ -29,10 +29,10 @@ type PullRequest = {
* @param body Text in which to search for mentioned issues
* @returns All found mentioned issues as GitHub issue references
*/
export function getMentionedIssueRefs(body: string): string[] {
export function getMentionedIssueRefs(body: string | null): string[] {
const issueUrls =
body.match(patterns.url.global)?.map((url) => toRef(url)) ?? [];
const issueRefs = body.match(patterns.ref) ?? [];
body?.match(patterns.url.global)?.map((url) => toRef(url)) ?? [];
const issueRefs = body?.match(patterns.ref) ?? [];
return issueUrls.concat(issueRefs).map((ref) => ref.trim());
}

Expand Down

0 comments on commit 791c35e

Please sign in to comment.