Skip to content

Fix duplicate tagpr PRs when CalVer advances between runs#326

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-duplicated-calver
Draft

Fix duplicate tagpr PRs when CalVer advances between runs#326
Copilot wants to merge 2 commits intomainfrom
copilot/fix-duplicated-calver

Conversation

Copy link
Contributor

Copilot AI commented Mar 13, 2026

With CalVer, when a tagpr PR is merged and tagged, a subsequent run sees an updated currVer, constructs a new rcBranch (e.g., tagpr-from-v2026.309.1), and finds no existing PR on that branch — so it creates a new one instead of recognizing the old one as stale. Result: two open tagpr PRs for the same day.

Root cause

The existing PR lookup is branch-exact:

rcBranch := fmt.Sprintf("tagpr-from-%s", currVer.Tag())  // changes when tag advances
pulls := gh.PullRequests.List(..., Head: "owner:"+rcBranch)
// if currVer changed since last run, finds nothing → creates duplicate PR

Changes

  • tagpr.go — stale PR detection: When the branch-specific lookup returns no PR, do a secondary search for any open tagpr PR (identified via isTagPR) targeting the same base branch on a different head branch. Collects labels from the stale PR to carry forward.
  • tagpr.go — stale PR cleanup: Before creating the new PR, close all detected stale tagpr PRs. Close errors are logged but non-fatal — the new PR creation proceeds regardless.

This ensures at most one tagpr PR is open at a time, regardless of how many times currVer advances between runs.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI linked an issue Mar 13, 2026 that may be closed by this pull request
When using Calendar Versioning, if a new tag is created between tagpr
runs (e.g., after a PR is merged and tagged), the next run sees a
different currVer, constructs a new rcBranch name, and can't find the
existing PR by branch lookup. This caused a new PR to be created,
leaving the old one open as a duplicate.

Fix: After the branch-specific PR lookup returns nothing, do a broader
search for any open tagpr PRs on other branches targeting the same base
branch. Collect their labels and close them before creating the new PR.

Co-authored-by: Songmu <177122+Songmu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix duplicated calver issue in tagpr Fix duplicate tagpr PRs when CalVer advances between runs Mar 13, 2026
Copilot AI requested a review from Songmu March 13, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

duplicated calver

2 participants