From 4f002b851d38f9c1490d757e48e6b16108070c4c Mon Sep 17 00:00:00 2001 From: jericho Date: Sun, 12 Nov 2023 20:05:36 -0500 Subject: [PATCH] Implement GetLinkedIssuesAsync in GitLab provider --- .../Provider/GitLabProvider.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/GitReleaseManager.Core/Provider/GitLabProvider.cs b/src/GitReleaseManager.Core/Provider/GitLabProvider.cs index f16f0c48..0a4b5a4a 100644 --- a/src/GitReleaseManager.Core/Provider/GitLabProvider.cs +++ b/src/GitReleaseManager.Core/Provider/GitLabProvider.cs @@ -391,10 +391,23 @@ public string GetIssueType(Issue issue) return issue.IsPullRequest ? "Merge Request" : "Issue"; } - public async Task GetLinkedIssueAsync(string owner, string repository, int issueNumber) + public Task> GetLinkedIssuesAsync(string owner, string repository, Issue issue) { - // This is a placeholder until I figure out if GitLab has a something equivalent to GitHub's "linked issue" - throw new NotImplementedException(); + return ExecuteAsync(() => + { + if (issue.IsPullRequest) + { + var closes = _gitLabClient.MergeRequests.ClosesIssues(issue.PublicNumber); + var issues = _mapper.Map>(closes); + return Task.FromResult(issues); + } + else + { + var closedBy = _gitLabClient.Issues.ClosedBy(GetGitLabProjectId(owner, repository), issue.PublicNumber); + var issues = _mapper.Map>(closedBy); + return Task.FromResult(issues); + } + }); } private int GetGitLabProjectId(string owner, string repository)