Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Validate repository names during interactive creation - #14313

Merged
BagToad merged 2 commits into
trunkfrom
14297-no-empty-repo-name
Sep 9, 2026
Merged

Validate repository names during interactive creation#14313
BagToad merged 2 commits into
trunkfrom
14297-no-empty-repo-name

Conversation

@sergiou87

@sergiou87 sergiou87 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #14297

Description

Interactive gh repo create accepted an empty repository name and continued through every remaining prompt. The command only failed after confirmation, when it tried to parse the incomplete OWNER/ repository reference. Users then had to restart the full creation flow.

This change validates the repository name immediately after input. Empty and whitespace-only values now stop the interactive flow with repository name cannot be blank, before owner, description, visibility, initialization, or confirmation prompts are shown.

Validation remains centralized beside repository-name parsing, so creating from scratch, from a template, and from a local repository all reject blank names consistently without additional I/O plumbing.

How did you test this change?

$ bin/gh repo create
? What would you like to do? Create a new repository on github.com from scratch
? Repository name
repository name cannot be blank

Added Test_createRun cases for empty and whitespace-only names. Both verify that validation fails immediately and produces no command output before the returned error is rendered by the command layer.

Key points

Blank-name validation runs immediately after the repository-name prompt and before owner parsing or later interactive prompts.

Whitespace-only input is treated as blank. Valid input is otherwise preserved and passed to existing parsing unchanged.

Notes for reviewers

Start with interactiveRepoNameAndOwner in pkg/cmd/repo/create/create.go, then review the interactive create from scratch with empty name and interactive create from scratch with whitespace-only name cases in pkg/cmd/repo/create/create_test.go.

The tests cover both invalid forms, immediate termination, the returned error, and empty stdout and stderr at the createRun layer.

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:

  • @sergiou87 will read and reply directly.
  • An agent will draft replies and @sergiou87 will read them before they are posted.
  • Nobody has explicitly committed to replying.

Interactive gh repo create previously accepted an empty repository name and continued through owner, description, visibility, initialization, and confirmation prompts. The command only rejected the resulting owner/ value when constructing the repository reference, forcing users to repeat the entire workflow.

Update interactive repository information collection to receive IOStreams so repository-name validation can report feedback at the point of entry. Retry the Repository name prompt while the submitted value is empty or contains only whitespace, and print the standard failure icon with a clear Repository name cannot be blank message after each invalid response.

Pass IOStreams through all interactive creation paths, including repositories created from scratch, from templates, and from local repositories. Valid names continue through the existing owner parsing and organization selection behavior unchanged.

Add a focused regression test that submits a whitespace-only name, verifies the prompt is repeated, then confirms a qualified OWNER/REPO response is parsed correctly and the validation message is written to stderr.

Fixes #14297

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f1c97983-6a41-4a95-b708-30a5c33d10bc
Copilot AI balanced review requested due to automatic review settings September 1, 2026 14:53

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 reported behavior and includes appropriate regression coverage.

Review tier: Balanced
Findings: None

What changed in this PR

Validates blank repository names early in interactive gh repo create flows.

Changes:

  • Re-prompts for empty or whitespace-only names with immediate feedback.
  • Routes existing IO streams through all interactive creation paths.
  • Adds coverage for retrying and qualified owner/name parsing.
File Description
pkg/​cmd/​repo/​create/​create.go Adds centralized interactive name validation.
pkg/​cmd/​repo/​create/​create_test.go Tests blank-name feedback and retry behavior.

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

@sergiou87
sergiou87 marked this pull request as ready for review September 1, 2026 14:59
@sergiou87
sergiou87 requested a review from a team as a code owner September 1, 2026 14:59
@sergiou87
sergiou87 requested a review from tidy-dev September 1, 2026 14:59

@tidy-dev tidy-dev 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.

✨ Works as expected.

Also had Copilot generate 32 permutations of this command non-inclusive of this change with no apparent regressions.

Comment thread pkg/cmd/repo/create/create.go Outdated
Comment thread pkg/cmd/repo/create/create.go Outdated
Blank repository names no longer trigger a re-prompt loop; interactiveRepoNameAndOwner now returns an error immediately, simplifying the function signature (drops the unused *iostreams.IOStreams param) and making create fail fast with a clear message. Updated tests accordingly.

Co-Authored-By: Kynan Ware <[email protected]>

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 validation is correctly placed and adequately covered by tests.

Review tier: Balanced
Findings: None

@sergiou87
sergiou87 requested a review from BagToad September 7, 2026 13:15
@BagToad
BagToad merged commit 9174ffb into trunk Sep 9, 2026
19 checks passed
@BagToad
BagToad deleted the 14297-no-empty-repo-name branch September 9, 2026 16:35
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 create accepts empty repo names

4 participants