Skip to content

issue develop: prevent .git/config corruption on repeated --name invocation#12651

Merged
BagToad merged 2 commits intocli:trunkfrom
gunadhya:fix-repeating-cmd-gh-issue-develop
Mar 4, 2026
Merged

issue develop: prevent .git/config corruption on repeated --name invocation#12651
BagToad merged 2 commits intocli:trunkfrom
gunadhya:fix-repeating-cmd-gh-issue-develop

Conversation

@gunadhya
Copy link
Contributor

@gunadhya gunadhya commented Feb 9, 2026

Fixes #12575
Reuse an existing linked branch (same name + repo) instead of failing when it already exists

In developRunCreate, when --name is provided:

  1. Look up linked branches for the issue
  2. Reuse a matching branch if it exists
  3. Only create a new linked branch if no match is found

@gunadhya gunadhya force-pushed the fix-repeating-cmd-gh-issue-develop branch from 4f5cc42 to bee197c Compare February 9, 2026 18:00
@gunadhya gunadhya force-pushed the fix-repeating-cmd-gh-issue-develop branch 2 times, most recently from 1a95ac4 to b38f677 Compare February 9, 2026 18:09
@gunadhya gunadhya marked this pull request as ready for review February 9, 2026 18:38
@gunadhya gunadhya requested a review from a team as a code owner February 9, 2026 18:38
@gunadhya gunadhya requested a review from BagToad February 9, 2026 18:38
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Feb 9, 2026
@BagToad BagToad changed the title issue develop: prevent .git/config corruption on repeated --name invocation issue develop: prevent .git/config corruption on repeated --name invocation Feb 12, 2026
@gcomneno
Copy link

Tested PR #12651 locally on Ubuntu 24.04 (linux/amd64) with Go 1.25.6.

Commands run:
gh pr checkout -R cli/cli 12651
go test -count=1 ./...

Result:
All packages passed.

Looked through the changes in pkg/cmd/issue/develop:

  • The implementation now checks existing linked branches (ListLinkedBranches) when a branch name is provided and reuses an existing linked branch for the same repo/name instead of attempting to recreate it.
  • There is an explicit guard for an empty branch name response ("API returned empty branch name"), which should prevent writing invalid git config entries (e.g. the [branch \"\"] / branch..gh-merge-base corruption described in Repeating the command gh issue develop twice breaks config #12575).
  • Added test coverage for: reuse path (including the TTY message), invalid base branch, and empty-name response.

This looks aligned with the expected behavior for repeated invocation and should avoid corrupting .git/config.

Copy link
Member

@BagToad BagToad left a comment

Choose a reason for hiding this comment

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

Sorry @gunadhya I forgot to submit my review comments! Just a couple nits and I think we can ship this.

Also huge thanks to @gcomneno for testing this out too.

branchID := ""
baseValidated := false
if opts.BaseBranch != "" {
opts.IO.StartProgressIndicator()
Copy link
Member

Choose a reason for hiding this comment

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

All these starting and stopping of the progress indicator can probably be simplified to one call to start it, a defer to catch the error cases and then a closing call to stop it.

Copy link
Member

Choose a reason for hiding this comment

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

We can also pass in a nice loading message with StartProgressIndicatorWithLabel

@gunadhya
Copy link
Contributor Author

gunadhya commented Mar 2, 2026

@BagToad no worries, added the requested changes
let me know if they look good

@BagToad BagToad self-requested a review March 4, 2026 01:14
Copy link
Member

@BagToad BagToad left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your efforts and patience!

@BagToad BagToad merged commit 4ea9076 into cli:trunk Mar 4, 2026
11 checks passed
@gunadhya
Copy link
Contributor Author

gunadhya commented Mar 5, 2026

glad to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repeating the command gh issue develop twice breaks config

4 participants