Skip to content

Commit d8835c2

Browse files
committed
Conditionally require discussion category
Only required when creating a repo discussion Fixes #40
1 parent 45d4977 commit d8835c2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

web-app/src/eventHandlers/pullRequestEventHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ Please fix the issues and recreate a new PR:
438438
}
439439
const discussionCategoryMatch = repoDiscussionCategories.find(
440440
(node) =>
441-
node?.name.trim().localeCompare(parsedItems.discussionCategoryName, undefined, {
441+
node?.name.trim().localeCompare(parsedItems.discussionCategoryName!, undefined, {
442442
sensitivity: 'accent'
443443
}) === 0
444444
);

web-app/src/services/parserService.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface ParsedMarkdownDiscussion {
66
repoOwner: string | undefined;
77
team: string | undefined;
88
teamOwner: string | undefined;
9-
discussionCategoryName: string;
9+
discussionCategoryName: string | undefined;
1010
postBody: string;
1111
postTitle: string;
1212
author: string;
@@ -86,7 +86,9 @@ export class ParserService {
8686
return teamName;
8787
}
8888

89-
public getDiscussionCategoryName(): string {
89+
public getDiscussionCategoryName(): string | undefined {
90+
const repoUrl = this.getTargetRepoUrl();
91+
if (!repoUrl) return;
9092
const rawCat = this._yamlHeader.category as string;
9193
const categoryName = rawCat?.split('/').pop()?.trim();
9294
if (!categoryName) throw new Error('Unable to get discussion category');

0 commit comments

Comments
 (0)