Skip to content

ParseRepository should use default workspace when only repo name is provided #27

@rbansal42

Description

@rbansal42

Problem

When a user has a default workspace configured, they still need to provide the full workspace/repo format for commands that take a --repo flag:

$ bb workspace set-default
Default workspace: hudle

$ bb pr list --repo laravel-12
✗ invalid repository format: laravel-12 (expected workspace/repo)

Expected Behavior

If a default workspace is set and the user provides just a repo name (without /), the CLI should use the default workspace:

$ bb pr list --repo laravel-12
# Should resolve to hudle/laravel-12 and work

Solution

Update ParseRepository() in internal/cmdutil/repository.go to:

  1. Check if the input contains / - if yes, parse as workspace/repo (current behavior)
  2. If no /, check for a default workspace via config.GetDefaultWorkspace()
  3. If default workspace exists, return (defaultWorkspace, repoFlag, nil)
  4. If no default workspace, return error suggesting to set one

Impact

This single change would improve UX for ALL commands that use --repo:

  • pr list/view/create/edit/merge/close/reopen/checkout/diff/checks/comment
  • pipeline list/view/run/stop/steps/logs
  • issue list/view/create/edit/close/reopen/delete/comment
  • branch list/create/delete
  • repo view/delete/fork/clone

Additional Changes

  • Update help text examples to show that repo-name is valid when default workspace is set
  • Update error message to mention bb workspace set-default as an option

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions