Skip to content

✨ add support for autoclosing issues when finishing a hotfix#241

Merged
candoumbe merged 3 commits intodevelopfrom
claude/add-support-for-autoclosing-issues
Mar 31, 2026
Merged

✨ add support for autoclosing issues when finishing a hotfix#241
candoumbe merged 3 commits intodevelopfrom
claude/add-support-for-autoclosing-issues

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Mar 31, 2026

Hotfix workflows can now automatically close issues/work items via the --issues parameter. When finishing a hotfix, specified issues are closed using the appropriate API after the merge completes.

Changes

  • Extended IGitFlowWithPullRequest.FinishHotfix() (GitHub): Overrides base implementation to close issues via GitHub API after hotfix merge
  • Extended IGitFlowWithPullRequest.FinishHotfix() (Azure DevOps): Overrides base implementation to close work items via Azure DevOps Work Item Tracking API after hotfix merge
  • Reuses existing Issues parameter: Leverages IPullRequest.Issues property (already available in both interfaces) - no new parameters required
  • Updated CHANGELOG.md: Documented feature addition for both platforms

Usage

./build.sh hotfix --issues 123,456,789

When on a hotfix branch, this will:

  1. Execute standard GitFlow hotfix completion (merge to main/develop, tag, push)
  2. Close issues/work items chore(deps): update dependency microsoft.sourcelink.github to v8 #123, #456, #789 via the appropriate API if token is available:
    • GitHub repositories: Uses GitHub API to close issues
    • Azure DevOps repositories: Uses Work Item Tracking API to close work items

The implementation follows the same pattern as FinishFeature() for consistency with existing PR-based workflows on both platforms.

@Claude Claude AI linked an issue Mar 31, 2026 that may be closed by this pull request
@Claude Claude AI changed the title [WIP] Add support for autoclosing issues on hotfix Add support for autoclosing issues when finishing a hotfix Mar 31, 2026
@Claude Claude AI requested a review from candoumbe March 31, 2026 19:28
@candoumbe
Copy link
Copy Markdown
Owner

@claude[agent]
add the same support for closing issues on AzureDevOps

@Claude
Copy link
Copy Markdown
Contributor Author

Claude AI commented Mar 31, 2026

@claude[agent]
add the same support for closing issues on AzureDevOps

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 --issues parameter.

@candoumbe candoumbe changed the title Add support for autoclosing issues when finishing a hotfix ✨ add support for autoclosing issues when finishing a hotfix Mar 31, 2026
@candoumbe candoumbe added enhancement ✨ New feature or request area:workflow Related to git branching strategy area:repo-github :octocat: Related to the GitHub Repository area:repo-azure-devops :microsoft: labels Mar 31, 2026
@candoumbe candoumbe marked this pull request as ready for review March 31, 2026 20:09
Copilot AI review requested due to automatic review settings March 31, 2026 20:09
@candoumbe candoumbe merged commit f803905 into develop Mar 31, 2026
8 checks passed
@candoumbe candoumbe deleted the claude/add-support-for-autoclosing-issues branch March 31, 2026 20:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +213 to +217
string gitRepositoryHttpsUrl = GitRepository.HttpsUrl!;
Match match = AzureDevOpsRegex.Match(gitRepositoryHttpsUrl!);

if (match.Success)
{
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +211 to +223
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>();
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
VssConnection vssConnection = new(new Uri(organizationUrl), new VssBasicCredential(string.Empty, AccessToken));
WorkItemTrackingHttpClient workItemClient = await vssConnection.GetClientAsync<WorkItemTrackingHttpClient>();

foreach (uint workItemId in Issues)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
foreach (uint workItemId in Issues)
foreach (uint workItemId in Issues.Distinct())

Copilot uses AI. Check for mistakes.
Comment on lines +155 to +163
if (Issues.AtLeastOnce() && !string.IsNullOrWhiteSpace(GitHubToken))
{
string repositoryName = GitRepository.GetGitHubName();
string owner = GitRepository.GetGitHubOwner();

GitHubClient gitHubClient = new(new ProductHeaderValue(repositoryName))
{
Credentials = new Credentials(GitHubToken)
};
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Credentials = new Credentials(GitHubToken)
};

foreach (uint issueNumber in Issues)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider de-duplicating Issues before iterating (e.g., Issues.Distinct()), otherwise passing duplicated issue numbers will trigger repeated API calls and log spam.

Suggested change
foreach (uint issueNumber in Issues)
foreach (uint issueNumber in Issues.Distinct())

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:repo-azure-devops :microsoft: area:repo-github :octocat: Related to the GitHub Repository area:workflow Related to git branching strategy enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Add support for autoclosing issues on hotfix

3 participants