Skip to content

Commit

Permalink
Fix #15
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Feb 22, 2024
1 parent e38e9bd commit 5246bdc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/ProfanityFilter.Action/Extensions/GitHubContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ internal static class GitHubContextExtensions
}

var number = context.Issue.Number;
var issueUrl = context.Payload!.Issue!.HtmlUrl;
var htmlUrl = GetHtmlUrl(context);

var linkedIssueOrPullRequest = context.EventName switch
{
"pull_request" => $"pull request [#{number}]({issueUrl}#{number})",
"issues" => $"issue [#{number}]({issueUrl}#{number})",
"issue_comment" => $"issue [#{number} (comment)]({issueUrl}#issuecomment-{context.Payload!.Comment!.Id})",
"pull_request" => $"pull request [#{number}]({htmlUrl}#{number})",
"issues" => $"issue [#{number}]({htmlUrl}#{number})",
"issue_comment" => $"issue [#{number} (comment)]({htmlUrl}#issuecomment-{context.Payload!.Comment!.Id})",

_ => "issue or pull request"
};
Expand All @@ -39,4 +39,13 @@ internal static class GitHubContextExtensions

return headerSummary;
}

private static string? GetHtmlUrl(Context context)
{
return context.EventName switch
{
"pull_request" => context.Payload?.PullRequest?.HtmlUrl,
_ => context.Payload?.Issue?.HtmlUrl
};
}
}

0 comments on commit 5246bdc

Please sign in to comment.