diff --git a/SS14.Labeller.Tests/CustomWebApplicationFactory.cs b/SS14.Labeller.Tests/CustomWebApplicationFactory.cs index 02c0eb7..d93aca7 100644 --- a/SS14.Labeller.Tests/CustomWebApplicationFactory.cs +++ b/SS14.Labeller.Tests/CustomWebApplicationFactory.cs @@ -18,9 +18,11 @@ namespace SS14.Labeller.Tests; [ExcludeFromCodeCoverage] public class CustomWebApplicationFactory : WebApplicationFactory { +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. public IGitHubApiClient GitHubApiClient { get; private set; } public IDiscourseClient DiscourseClient { get; private set; } public IDiscourseTopicsRepository TopicsRepository { get; private set; } +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. /// protected override void ConfigureWebHost(IWebHostBuilder builder) @@ -46,6 +48,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { { "Discourse:ApiKey", "wawa" }, { "Discourse:Username", "aw" }, + { "Discourse:Enable", "true" }, { "Discourse:DiscussionCategoryId", "42" }, { "Discourse:Url", "http://wa.wa" }, { "GitHub:WebhookSecret", IntegrationTests.HookSecret }, diff --git a/SS14.Labeller.Tests/GitHubApi/GithubRetryHandlerTests.cs b/SS14.Labeller.Tests/GitHubApi/GithubRetryHandlerTests.cs index 9ee15ab..df1a694 100644 --- a/SS14.Labeller.Tests/GitHubApi/GithubRetryHandlerTests.cs +++ b/SS14.Labeller.Tests/GitHubApi/GithubRetryHandlerTests.cs @@ -36,7 +36,7 @@ public void Setup() public void SendAsync_SuccessfulRequest() { // Arrange - _mockInnerHandler.Send(Arg.Any(), Arg.Any()) + _mockInnerHandler.SendStub(Arg.Any(), Arg.Any()) .Returns(Task.FromResult(new HttpResponseMessage { StatusCode = HttpStatusCode.OK })); var handler = new GithubRetryHandler(_mockInnerHandler, _config, _logger); @@ -46,14 +46,14 @@ public void SendAsync_SuccessfulRequest() var result = httpClient.SendAsync(_httpRequestMessage, default).Result; // Assert - Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); + Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK)); } [Test] public void SendAsync_NetworkErrorRetries() { // Arrange - _mockInnerHandler.Send(Arg.Any(), Arg.Any()) + _mockInnerHandler.SendStub(Arg.Any(), Arg.Any()) .Returns( _=> throw new HttpRequestException(HttpRequestError.ConnectionError), _=> Task.FromResult(new HttpResponseMessage { StatusCode = HttpStatusCode.OK }) @@ -66,7 +66,7 @@ public void SendAsync_NetworkErrorRetries() var result = httpClient.SendAsync(_httpRequestMessage, default).Result; // Assert - Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); + Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK)); } [Test] @@ -84,7 +84,7 @@ public void SendAsync_CalculateNextRequestTimeWithRateLimits() var response2 = new HttpResponseMessage(HttpStatusCode.OK); - _mockInnerHandler.Send(Arg.Any(), Arg.Any()) + _mockInnerHandler.SendStub(Arg.Any(), Arg.Any()) .Returns(response1, response2); var handler = new GithubRetryHandler(_mockInnerHandler, _config, _logger); @@ -103,7 +103,7 @@ public void SendAsync_CalculateNextRequestTimeWithRateLimits() public void SendAsync_MaxRetryExceeded() { // Arrange - _mockInnerHandler.Send(Arg.Any(), Arg.Any()) + _mockInnerHandler.SendStub(Arg.Any(), Arg.Any()) .ThrowsAsync(new HttpRequestException(HttpRequestError.ConnectionError)); _gitHubConfig.MaxRetryAttempt = 2; @@ -125,10 +125,10 @@ public class MockHttpMessageHandler : HttpMessageHandler { protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - return Send(request, cancellationToken); + return SendStub(request, cancellationToken); } - public virtual Task Send(HttpRequestMessage request, CancellationToken cancellationToken) + public virtual Task SendStub(HttpRequestMessage request, CancellationToken cancellationToken) { throw new NotImplementedException(); } diff --git a/SS14.Labeller.Tests/IntegrationTests.PullRequest.cs b/SS14.Labeller.Tests/IntegrationTests.PullRequest.cs index 0576b00..db5e9ca 100644 --- a/SS14.Labeller.Tests/IntegrationTests.PullRequest.cs +++ b/SS14.Labeller.Tests/IntegrationTests.PullRequest.cs @@ -310,4 +310,45 @@ await _applicationFactory.GitHubApiClient Arg.Any() ); } + + [Test] + public async Task PullRequest_TaggedWithNeedsDiscussionAndNoExistingDiscussion_NewDiscourseThreadSaved() + { + // Arrange + const string fileName = "pull_request_needs_discussion.json"; + var requestContent = await CreateRequestContent(fileName, "pull_request"); + _applicationFactory.TopicsRepository + .HasTopic("Fildrance", "SS14.Labeller", 36, Arg.Any()) + .Returns(false); + + _applicationFactory.DiscourseClient.CreateTopic(42, Arg.Any(), Arg.Any(), Arg.Any()) + .Returns(Task.FromResult(new DiscourseCreatedPost{PostUrl = "https://discourse.example.com/t/42", TopicId = 43})); + + // Act + await _client.PostAsync("/webhook", requestContent); + + // Assert + await _applicationFactory.TopicsRepository + .Received() + .Add("Fildrance", "SS14.Labeller", 36, 43, Arg.Any()); + } + + [Test] + public async Task PullRequest_TaggedWithNeedsDiscussionAndExistingDiscussion_NoNewDiscussionCreated() + { + // Arrange + const string fileName = "pull_request_needs_discussion.json"; + var requestContent = await CreateRequestContent(fileName, "pull_request"); + _applicationFactory.TopicsRepository + .HasTopic("Fildrance", "SS14.Labeller", 36, Arg.Any()) + .Returns(true); + + + // Act + await _client.PostAsync("/webhook", requestContent); + + // Assert + await _applicationFactory.DiscourseClient.DidNotReceive() + .CreateTopic(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()); + } } \ No newline at end of file diff --git a/SS14.Labeller.Tests/Resources/pull_request_needs_discussion.json b/SS14.Labeller.Tests/Resources/pull_request_needs_discussion.json new file mode 100644 index 0000000..610263a --- /dev/null +++ b/SS14.Labeller.Tests/Resources/pull_request_needs_discussion.json @@ -0,0 +1,504 @@ +{ + "action": "labeled", + "number": 36, + "pull_request": { + "url": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls/36", + "id": 3694250807, + "node_id": "PR_kwDOEYelBM7cMcs3", + "html_url": "https://github.com/Fildrance/SS14.Labeller/pull/36", + "diff_url": "https://github.com/Fildrance/SS14.Labeller/pull/36.diff", + "patch_url": "https://github.com/Fildrance/SS14.Labeller/pull/36.patch", + "issue_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/36", + "number": 36, + "state": "open", + "locked": false, + "title": "asdasd", + "user": { + "login": "Fildrance", + "id": 14752842, + "node_id": "MDQ6VXNlcjE0NzUyODQy", + "avatar_url": "https://avatars.githubusercontent.com/u/14752842?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Fildrance", + "html_url": "https://github.com/Fildrance", + "followers_url": "https://api.github.com/users/Fildrance/followers", + "following_url": "https://api.github.com/users/Fildrance/following{/other_user}", + "gists_url": "https://api.github.com/users/Fildrance/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Fildrance/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Fildrance/subscriptions", + "organizations_url": "https://api.github.com/users/Fildrance/orgs", + "repos_url": "https://api.github.com/users/Fildrance/repos", + "events_url": "https://api.github.com/users/Fildrance/events{/privacy}", + "received_events_url": "https://api.github.com/users/Fildrance/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "body": null, + "created_at": "2026-05-16T10:28:01Z", + "updated_at": "2026-05-16T10:28:12Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "3644cd66993e9b78b0ec5b5d6a69ba716bfe5a05", + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 2335502209, + "node_id": "MDU6TGFiZWwyMzM1NTAyMjA5", + "url": "https://api.github.com/repos/Fildrance/SS14.Labeller/labels/invalid", + "name": "invalid", + "color": "e4e669", + "default": true, + "description": "This doesn't seem right" + } + ], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls/36/commits", + "review_comments_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls/36/comments", + "review_comment_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/36/comments", + "statuses_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/statuses/5688f3af2bc64e118a16e1893a3042e4611791f7", + "head": { + "label": "Fildrance:tes-test-2", + "ref": "tes-test-2", + "sha": "5688f3af2bc64e118a16e1893a3042e4611791f7", + "user": { + "login": "Fildrance", + "id": 14752842, + "node_id": "MDQ6VXNlcjE0NzUyODQy", + "avatar_url": "https://avatars.githubusercontent.com/u/14752842?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Fildrance", + "html_url": "https://github.com/Fildrance", + "followers_url": "https://api.github.com/users/Fildrance/followers", + "following_url": "https://api.github.com/users/Fildrance/following{/other_user}", + "gists_url": "https://api.github.com/users/Fildrance/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Fildrance/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Fildrance/subscriptions", + "organizations_url": "https://api.github.com/users/Fildrance/orgs", + "repos_url": "https://api.github.com/users/Fildrance/repos", + "events_url": "https://api.github.com/users/Fildrance/events{/privacy}", + "received_events_url": "https://api.github.com/users/Fildrance/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 294102276, + "node_id": "MDEwOlJlcG9zaXRvcnkyOTQxMDIyNzY=", + "name": "SS14.Labeller", + "full_name": "Fildrance/SS14.Labeller", + "private": false, + "owner": { + "login": "Fildrance", + "id": 14752842, + "node_id": "MDQ6VXNlcjE0NzUyODQy", + "avatar_url": "https://avatars.githubusercontent.com/u/14752842?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Fildrance", + "html_url": "https://github.com/Fildrance", + "followers_url": "https://api.github.com/users/Fildrance/followers", + "following_url": "https://api.github.com/users/Fildrance/following{/other_user}", + "gists_url": "https://api.github.com/users/Fildrance/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Fildrance/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Fildrance/subscriptions", + "organizations_url": "https://api.github.com/users/Fildrance/orgs", + "repos_url": "https://api.github.com/users/Fildrance/repos", + "events_url": "https://api.github.com/users/Fildrance/events{/privacy}", + "received_events_url": "https://api.github.com/users/Fildrance/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/Fildrance/SS14.Labeller", + "description": "Simple tool for forming and keeping track of employees skill development.", + "fork": false, + "url": "https://api.github.com/repos/Fildrance/SS14.Labeller", + "forks_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/forks", + "keys_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/teams", + "hooks_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/hooks", + "issue_events_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/events{/number}", + "events_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/events", + "assignees_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/assignees{/user}", + "branches_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/branches{/branch}", + "tags_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/tags", + "blobs_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/languages", + "stargazers_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/stargazers", + "contributors_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/contributors", + "subscribers_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/subscribers", + "subscription_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/subscription", + "commits_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/contents/{+path}", + "compare_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/merges", + "archive_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/downloads", + "issues_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues{/number}", + "pulls_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/labels{/name}", + "releases_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/releases{/id}", + "deployments_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/deployments", + "created_at": "2020-09-09T12:11:04Z", + "updated_at": "2023-11-30T18:45:58Z", + "pushed_at": "2026-05-16T10:27:53Z", + "git_url": "git://github.com/Fildrance/SS14.Labeller.git", + "ssh_url": "git@github.com:Fildrance/SS14.Labeller.git", + "clone_url": "https://github.com/Fildrance/SS14.Labeller.git", + "svn_url": "https://github.com/Fildrance/SS14.Labeller", + "homepage": null, + "size": 1069, + "stargazers_count": 0, + "watchers_count": 0, + "language": "CSS", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "has_pull_requests": true, + "pull_request_creation_policy": "all", + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 5, + "watchers": 0, + "default_branch": "master", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "Fildrance:test-test-3", + "ref": "test-test-3", + "sha": "f3856fb23e6765bbdbe2b127dc3227a92b41d2ae", + "user": { + "login": "Fildrance", + "id": 14752842, + "node_id": "MDQ6VXNlcjE0NzUyODQy", + "avatar_url": "https://avatars.githubusercontent.com/u/14752842?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Fildrance", + "html_url": "https://github.com/Fildrance", + "followers_url": "https://api.github.com/users/Fildrance/followers", + "following_url": "https://api.github.com/users/Fildrance/following{/other_user}", + "gists_url": "https://api.github.com/users/Fildrance/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Fildrance/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Fildrance/subscriptions", + "organizations_url": "https://api.github.com/users/Fildrance/orgs", + "repos_url": "https://api.github.com/users/Fildrance/repos", + "events_url": "https://api.github.com/users/Fildrance/events{/privacy}", + "received_events_url": "https://api.github.com/users/Fildrance/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "repo": { + "id": 294102276, + "node_id": "MDEwOlJlcG9zaXRvcnkyOTQxMDIyNzY=", + "name": "SS14.Labeller", + "full_name": "Fildrance/SS14.Labeller", + "private": false, + "owner": { + "login": "Fildrance", + "id": 14752842, + "node_id": "MDQ6VXNlcjE0NzUyODQy", + "avatar_url": "https://avatars.githubusercontent.com/u/14752842?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Fildrance", + "html_url": "https://github.com/Fildrance", + "followers_url": "https://api.github.com/users/Fildrance/followers", + "following_url": "https://api.github.com/users/Fildrance/following{/other_user}", + "gists_url": "https://api.github.com/users/Fildrance/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Fildrance/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Fildrance/subscriptions", + "organizations_url": "https://api.github.com/users/Fildrance/orgs", + "repos_url": "https://api.github.com/users/Fildrance/repos", + "events_url": "https://api.github.com/users/Fildrance/events{/privacy}", + "received_events_url": "https://api.github.com/users/Fildrance/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/Fildrance/SS14.Labeller", + "description": "Simple tool for forming and keeping track of employees skill development.", + "fork": false, + "url": "https://api.github.com/repos/Fildrance/SS14.Labeller", + "forks_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/forks", + "keys_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/teams", + "hooks_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/hooks", + "issue_events_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/events{/number}", + "events_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/events", + "assignees_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/assignees{/user}", + "branches_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/branches{/branch}", + "tags_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/tags", + "blobs_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/languages", + "stargazers_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/stargazers", + "contributors_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/contributors", + "subscribers_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/subscribers", + "subscription_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/subscription", + "commits_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/contents/{+path}", + "compare_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/merges", + "archive_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/downloads", + "issues_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues{/number}", + "pulls_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/labels{/name}", + "releases_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/releases{/id}", + "deployments_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/deployments", + "created_at": "2020-09-09T12:11:04Z", + "updated_at": "2023-11-30T18:45:58Z", + "pushed_at": "2026-05-16T10:27:53Z", + "git_url": "git://github.com/Fildrance/SS14.Labeller.git", + "ssh_url": "git@github.com:Fildrance/SS14.Labeller.git", + "clone_url": "https://github.com/Fildrance/SS14.Labeller.git", + "svn_url": "https://github.com/Fildrance/SS14.Labeller", + "homepage": null, + "size": 1069, + "stargazers_count": 0, + "watchers_count": 0, + "language": "CSS", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "has_pull_requests": true, + "pull_request_creation_policy": "all", + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 5, + "watchers": 0, + "default_branch": "master", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { "href": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls/36" }, + "html": { "href": "https://github.com/Fildrance/SS14.Labeller/pull/36" }, + "issue": { "href": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/36" }, + "comments": { "href": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/36/comments" }, + "review_comments": { "href": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls/36/comments" }, + "review_comment": { "href": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls/comments{/number}" }, + "commits": { "href": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls/36/commits" }, + "statuses": { "href": "https://api.github.com/repos/Fildrance/SS14.Labeller/statuses/5688f3af2bc64e118a16e1893a3042e4611791f7" } + }, + "author_association": "OWNER", + "auto_merge": null, + "assignee": null, + "active_lock_reason": null, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "clean", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 + }, + "label": { + "id": 2335502209, + "node_id": "MDU6TGFiZWwyMzM1NTAyMjA5", + "url": "https://api.github.com/repos/Fildrance/SS14.Labeller/labels/invalid", + "name": "S: Undergoing Discussion", + "color": "e4e669", + "default": true, + "description": "This doesn't seem right" + }, + "repository": { + "id": 294102276, + "node_id": "MDEwOlJlcG9zaXRvcnkyOTQxMDIyNzY=", + "name": "SS14.Labeller", + "full_name": "Fildrance/SS14.Labeller", + "private": false, + "owner": { + "login": "Fildrance", + "id": 14752842, + "node_id": "MDQ6VXNlcjE0NzUyODQy", + "avatar_url": "https://avatars.githubusercontent.com/u/14752842?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Fildrance", + "html_url": "https://github.com/Fildrance", + "followers_url": "https://api.github.com/users/Fildrance/followers", + "following_url": "https://api.github.com/users/Fildrance/following{/other_user}", + "gists_url": "https://api.github.com/users/Fildrance/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Fildrance/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Fildrance/subscriptions", + "organizations_url": "https://api.github.com/users/Fildrance/orgs", + "repos_url": "https://api.github.com/users/Fildrance/repos", + "events_url": "https://api.github.com/users/Fildrance/events{/privacy}", + "received_events_url": "https://api.github.com/users/Fildrance/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + }, + "html_url": "https://github.com/Fildrance/SS14.Labeller", + "description": "Simple tool for forming and keeping track of employees skill development.", + "fork": false, + "url": "https://api.github.com/repos/Fildrance/SS14.Labeller", + "forks_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/forks", + "keys_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/teams", + "hooks_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/hooks", + "issue_events_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/events{/number}", + "events_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/events", + "assignees_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/assignees{/user}", + "branches_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/branches{/branch}", + "tags_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/tags", + "blobs_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/languages", + "stargazers_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/stargazers", + "contributors_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/contributors", + "subscribers_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/subscribers", + "subscription_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/subscription", + "commits_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/contents/{+path}", + "compare_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/merges", + "archive_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/downloads", + "issues_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/issues{/number}", + "pulls_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/labels{/name}", + "releases_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/releases{/id}", + "deployments_url": "https://api.github.com/repos/Fildrance/SS14.Labeller/deployments", + "created_at": "2020-09-09T12:11:04Z", + "updated_at": "2023-11-30T18:45:58Z", + "pushed_at": "2026-05-16T10:27:53Z", + "git_url": "git://github.com/Fildrance/SS14.Labeller.git", + "ssh_url": "git@github.com:Fildrance/SS14.Labeller.git", + "clone_url": "https://github.com/Fildrance/SS14.Labeller.git", + "svn_url": "https://github.com/Fildrance/SS14.Labeller", + "homepage": null, + "size": 1069, + "stargazers_count": 0, + "watchers_count": 0, + "language": "CSS", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "has_pull_requests": true, + "pull_request_creation_policy": "all", + "topics": [], + "visibility": "public", + "forks": 0, + "open_issues": 5, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "Fildrance", + "id": 14752842, + "node_id": "MDQ6VXNlcjE0NzUyODQy", + "avatar_url": "https://avatars.githubusercontent.com/u/14752842?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Fildrance", + "html_url": "https://github.com/Fildrance", + "followers_url": "https://api.github.com/users/Fildrance/followers", + "following_url": "https://api.github.com/users/Fildrance/following{/other_user}", + "gists_url": "https://api.github.com/users/Fildrance/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Fildrance/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Fildrance/subscriptions", + "organizations_url": "https://api.github.com/users/Fildrance/orgs", + "repos_url": "https://api.github.com/users/Fildrance/repos", + "events_url": "https://api.github.com/users/Fildrance/events{/privacy}", + "received_events_url": "https://api.github.com/users/Fildrance/received_events", + "type": "User", + "user_view_type": "public", + "site_admin": false + } +} diff --git a/SS14.Labeller/Handlers/LabelPullRequestHandler.cs b/SS14.Labeller/Handlers/LabelPullRequestHandler.cs index a70cbec..70a6e23 100644 --- a/SS14.Labeller/Handlers/LabelPullRequestHandler.cs +++ b/SS14.Labeller/Handlers/LabelPullRequestHandler.cs @@ -135,7 +135,7 @@ private async Task OnLabelAdd(PullRequestEvent request, CancellationToken ct, st return; var exists = await topicsRepository.HasTopic(repoOwner, repoName, prNumber, ct); - if (exists) + if (!exists) { // need to make a new discussion. var topic = await discourseClient.CreateTopic(