Skip to content

Allow repo set-default --unset without an argument - #14540

Merged
williammartin merged 1 commit into
trunkfrom
williammartin-fix-issue-14521
Sep 29, 2026
Merged

williammartin merged 1 commit into
trunkfrom
williammartin-fix-issue-14521

Conversation

@williammartin

@williammartin williammartin commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Fixes #14521

Description

gh repo set-default --unset incorrectly required a repository argument when stdin was not interactive. The command does not use a repository argument when unsetting the current default.

This exempts --unset from the non-interactive repository requirement, matching the existing behavior for --view. Constructor tests cover argument-free non-interactive --unset and --view while preserving the error for an ordinary argument-free non-interactive invocation.

How did you test this change?

session.mp4

Key points

This change does not alter the existing acceptance of a repository argument with --unset; deciding whether that ignored argument should be rejected is outside this fix.

Notes for reviewers

Start with the non-interactive validation condition in NewCmdSetDefault, then review the constructor test cases that distinguish --view, --unset, and ordinary invocation.

Authorship and follow-up

Who wrote this:

  • A human wrote it.
  • An agent wrote it under close human direction.
  • An agent wrote it independently, and no human has guided the implementation beyond the initial prompt.

Who answers review comments:

  • @williammartin will read and reply directly. Name the account.
  • An agent will draft replies and @username will read them before they are posted.
  • Nobody has explicitly committed to replying.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 28, 2026 06:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused implementation matches the requested behavior and includes appropriate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Allows non-interactive gh repo set-default --unset without a repository argument, fixing #14521.

Changes:

  • Exempts --unset from non-interactive repository validation.
  • Adds regression coverage for --unset, --view, and ordinary invocation.
File Description
pkg/​cmd/​repo/​setdefault/​setdefault.go Updates non-interactive validation.
pkg/​cmd/​repo/​setdefault/​setdefault_test.go Covers affected flag and TTY behavior.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@williammartin
williammartin merged commit 0f6de7b into trunk Sep 29, 2026
54 checks passed
@williammartin
williammartin deleted the williammartin-fix-issue-14521 branch September 29, 2026 14:24
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.

gh repo set-default --unset should not require a repository argument

3 participants