Skip to content

Commit

Permalink
Conditionally require discussion category
Browse files Browse the repository at this point in the history
Only required when creating a repo discussion
Fixes #40
  • Loading branch information
philip-gai committed Dec 2, 2021
1 parent 45d4977 commit d8835c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion web-app/src/eventHandlers/pullRequestEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ Please fix the issues and recreate a new PR:
}
const discussionCategoryMatch = repoDiscussionCategories.find(
(node) =>
node?.name.trim().localeCompare(parsedItems.discussionCategoryName, undefined, {
node?.name.trim().localeCompare(parsedItems.discussionCategoryName!, undefined, {
sensitivity: 'accent'
}) === 0
);
Expand Down
6 changes: 4 additions & 2 deletions web-app/src/services/parserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface ParsedMarkdownDiscussion {
repoOwner: string | undefined;
team: string | undefined;
teamOwner: string | undefined;
discussionCategoryName: string;
discussionCategoryName: string | undefined;
postBody: string;
postTitle: string;
author: string;
Expand Down Expand Up @@ -86,7 +86,9 @@ export class ParserService {
return teamName;
}

public getDiscussionCategoryName(): string {
public getDiscussionCategoryName(): string | undefined {
const repoUrl = this.getTargetRepoUrl();
if (!repoUrl) return;
const rawCat = this._yamlHeader.category as string;
const categoryName = rawCat?.split('/').pop()?.trim();
if (!categoryName) throw new Error('Unable to get discussion category');
Expand Down

0 comments on commit d8835c2

Please sign in to comment.