Skip to content

Close the issue after a Self-merge unless it is already closed - #186

Merged
JacobStephens2 merged 5 commits into
mainfrom
issue-181
Sep 30, 2026
Merged

JacobStephens2 merged 5 commits into
mainfrom
issue-181

Conversation

@JacobStephens2

Copy link
Copy Markdown
Owner

Summary

After a Self-merge, thirdshift no longer tries to predict whether GitHub will close the issue. It closes the issue itself unless the issue is already closed.

 after_merge
   delete Issue branch on origin
-  close_unless_merge_does
-    if merge_closes_issue (gh pr view --json baseRefName,closingIssuesReferences + gh repo view)
-       or issue is closed: return
+  close_unless_closed
+    if issue is closed: return
     gh issue close --comment "Closed by #<pr>, merged into <base> by a thirdshift Merge run."
  • github::merge_closes_issue is removed. Its closingIssuesReferences field doesn't exist in gh 2.45.
  • In the fake gh, pr merge no longer closes the issues a PR body names, since GitHub may not close them either. --json now rejects unknown fields with gh's Unknown JSON field error, on pr view (with and without --jq), pr list and issue view. The fake's repo view is gone because nothing calls it any more.
  • The Self-merge entry in CONTEXT.md now says: "the issue closed by thirdshift, unless it is already closed."

Evidence

  • Before: the new tests failed on main's code:
    a_merge_into_the_default_branch_closes_the_issue_github_leaves_open
      comments["7"]: Null != ["Closed by #1, merged into main by a thirdshift Merge run."]
    no_gh_call_asks_for_the_prs_closing_issue_references
      gh pr view issue-7 --json baseRefName,closingIssuesReferences asks for a field gh 2.45 does not have
    
    After: cargo test passes every suite, and cargo clippy --all-targets and cargo fmt --check are clean. New or changed tests in tests/merge_run.rs:
    merge into main, PR says "Closes #7", fake leaves #7 open  -> #7 CLOSED with thirdshift's comment, no warning
    merge, after-merge hook closes #7 first                    -> no gh issue close, no comment
    every gh call in a Merge run                               -> none mentions closingIssuesReferences
    
    The existing tests for a merge into a non-default base and for a failed gh issue close (exit 0 plus the "could not close issue Numbered Issue branches after a merged or closed PR #7…" warning) pass unchanged.

Merge Danger

Door: two-way

A revert brings back the old behaviour. The only lasting effect is a duplicate close comment, in the accepted race where GitHub closes the issue at the moment thirdshift checks.

Blast Radius: small

It only affects the post-merge close step of a Merge run, which never fails the Run. Issues that GitHub closes may occasionally get an extra thirdshift comment as well.

Unaddressed findings

Standards

  • The explicit closingIssuesReferences test duplicates the fake's rejection. Kept on purpose: the spec asks that "a test fails if one does", and a named test says why better than a warning buried in stderr.
  • "default branch" in test names now suggests a distinction the code no longer makes. Kept: the names match the acceptance criteria and pin the exact scenario from Release script resumes an interrupted release #158 and One Run notification per Spec run #148.
  • The closing comment for main is written inline instead of through a helper. It's a single use, moved from a deleted test, so a helper isn't worth it.
  • "gh 2.45" is pinned in both the fake's docstring and the test message. It documents the real version seen in the report. Out of scope: the spec rules out setting a minimum gh version.

Spec

None unaddressed. The fake's partial rejection of unknown fields was fixed across pr view --jq, pr list and issue view.

Closes #181

🤖 Generated with Claude Code

JacobStephens2 and others added 5 commits September 30, 2026 13:08
GitHub may not close a PR's linked issue on merge, and gh 2.45 has no
closingIssuesReferences field, so thirdshift no longer predicts whether the
merge closes the issue. The fake gh no longer closes issues on merge and
rejects unknown --json fields as gh does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JacobStephens2
JacobStephens2 merged commit c5ae0c1 into main Sep 30, 2026
13 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-181 branch September 30, 2026 13:48
@JacobStephens2 JacobStephens2 linked an issue Sep 30, 2026 that may be closed by this pull request
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.

Merge run leaves the issue open when the merge doesn't close it

1 participant