✨ add support for autoclosing issues when finishing a hotfix#241
✨ add support for autoclosing issues when finishing a hotfix#241
Conversation
Agent-Logs-Url: https://github.com/candoumbe/Pipelines/sessions/3b736f20-0d4e-4542-9591-b91589bde7a2 Co-authored-by: candoumbe <13941078+candoumbe@users.noreply.github.com>
|
@claude[agent] |
Agent-Logs-Url: https://github.com/candoumbe/Pipelines/sessions/499c4229-79b9-4522-b63f-2c00ebedd0e8 Co-authored-by: candoumbe <13941078+candoumbe@users.noreply.github.com>
Added Azure DevOps support in commit 441a710. The implementation uses the Work Item Tracking API to close work items when finishing a hotfix with the |
There was a problem hiding this comment.
Pull request overview
Adds post-merge issue/work-item autoclosing to the hotfix finish workflow for both GitHub and Azure DevOps implementations, using the existing --issues parameter and documenting the feature in the changelog.
Changes:
- GitHub: override
FinishHotfix()to close specified GitHub issues via Octokit after hotfix merge completes. - Azure DevOps: override
FinishHotfix()to close specified work items via Work Item Tracking API after hotfix merge completes. - Document the new behavior in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/Candoumbe.Pipelines/Components/GitHub/IGitFlowWithPullRequest.cs | Adds hotfix-finish issue closing using GitHub API |
| src/Candoumbe.Pipelines.Components.AzureDevOps/IGitFlowWithPullRequest.cs | Adds hotfix-finish work item closing using Azure DevOps WIT API |
| CHANGELOG.md | Documents hotfix autoclosing support via --issues |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| string gitRepositoryHttpsUrl = GitRepository.HttpsUrl!; | ||
| Match match = AzureDevOpsRegex.Match(gitRepositoryHttpsUrl!); | ||
|
|
||
| if (match.Success) | ||
| { |
There was a problem hiding this comment.
FinishHotfix() silently skips closing work items when the Azure DevOps repository URL doesn't match AzureDevOpsRegex. FinishFeature() logs an error in the equivalent situation; doing the same here would make failures diagnosable (e.g., log Error(...) in an else branch when match.Success is false).
| if (Issues.AtLeastOnce() && !string.IsNullOrWhiteSpace(AccessToken)) | ||
| { | ||
| string gitRepositoryHttpsUrl = GitRepository.HttpsUrl!; | ||
| Match match = AzureDevOpsRegex.Match(gitRepositoryHttpsUrl!); | ||
|
|
||
| if (match.Success) | ||
| { | ||
| const string repositoryBaseUrl = "https://dev.azure.com"; | ||
| string organization = match.Groups["organisation"].Value; | ||
| string organizationUrl = $"{repositoryBaseUrl}/{organization}"; | ||
|
|
||
| VssConnection vssConnection = new(new Uri(organizationUrl), new VssBasicCredential(string.Empty, AccessToken)); | ||
| WorkItemTrackingHttpClient workItemClient = await vssConnection.GetClientAsync<WorkItemTrackingHttpClient>(); |
There was a problem hiding this comment.
This hotfix implementation checks AccessToken but never prompts the user for a token when SkipConfirmation is false (unlike FinishFeature() which falls back to PromptForInput). This makes --issues ... appear to do nothing in interactive runs unless the token is already configured; consider reusing the same token-acquisition pattern as FinishFeature() for consistency.
| VssConnection vssConnection = new(new Uri(organizationUrl), new VssBasicCredential(string.Empty, AccessToken)); | ||
| WorkItemTrackingHttpClient workItemClient = await vssConnection.GetClientAsync<WorkItemTrackingHttpClient>(); | ||
|
|
||
| foreach (uint workItemId in Issues) |
There was a problem hiding this comment.
Consider de-duplicating Issues before iterating (e.g., Issues.Distinct()), otherwise passing duplicated IDs (or default config duplication) will trigger repeated API calls and log spam.
| foreach (uint workItemId in Issues) | |
| foreach (uint workItemId in Issues.Distinct()) |
| if (Issues.AtLeastOnce() && !string.IsNullOrWhiteSpace(GitHubToken)) | ||
| { | ||
| string repositoryName = GitRepository.GetGitHubName(); | ||
| string owner = GitRepository.GetGitHubOwner(); | ||
|
|
||
| GitHubClient gitHubClient = new(new ProductHeaderValue(repositoryName)) | ||
| { | ||
| Credentials = new Credentials(GitHubToken) | ||
| }; |
There was a problem hiding this comment.
This hotfix implementation checks GitHubToken but never prompts the user for a token when SkipConfirmation is false (unlike FinishFeature() which falls back to PromptForInput). This makes --issues ... appear to do nothing in interactive runs unless the token is already configured; consider reusing the same token-acquisition pattern as FinishFeature() for consistency.
| Credentials = new Credentials(GitHubToken) | ||
| }; | ||
|
|
||
| foreach (uint issueNumber in Issues) |
There was a problem hiding this comment.
Consider de-duplicating Issues before iterating (e.g., Issues.Distinct()), otherwise passing duplicated issue numbers will trigger repeated API calls and log spam.
| foreach (uint issueNumber in Issues) | |
| foreach (uint issueNumber in Issues.Distinct()) |
Hotfix workflows can now automatically close issues/work items via the
--issuesparameter. When finishing a hotfix, specified issues are closed using the appropriate API after the merge completes.Changes
IGitFlowWithPullRequest.FinishHotfix()(GitHub): Overrides base implementation to close issues via GitHub API after hotfix mergeIGitFlowWithPullRequest.FinishHotfix()(Azure DevOps): Overrides base implementation to close work items via Azure DevOps Work Item Tracking API after hotfix mergeIssuesparameter: LeveragesIPullRequest.Issuesproperty (already available in both interfaces) - no new parameters requiredUsage
When on a hotfix branch, this will:
The implementation follows the same pattern as
FinishFeature()for consistency with existing PR-based workflows on both platforms.