Skip to content

fix: clarify --default-branch semantics across scan and repository#1269

Closed
Martin Torp (mtorp) wants to merge 1 commit intov1.xfrom
martin/eng-4940-default-branch-flag-clarity
Closed

fix: clarify --default-branch semantics across scan and repository#1269
Martin Torp (mtorp) wants to merge 1 commit intov1.xfrom
martin/eng-4940-default-branch-flag-clarity

Conversation

@mtorp
Copy link
Copy Markdown
Contributor

Summary

socket scan create --default-branch is a boolean toggle, but meow silently discards the value when users pass --default-branch=<name> — a common mistake because socket repository create --default-branch was a string flag that accepted a value. When that happens, the scan is created without being marked as the default branch, so it never lands in the Main/PR dashboard tabs.

  • scan create: reject --default-branch=<value> with an InputError that points users at the correct form (--default-branch on its own, with --branch=<name> to name the branch).
  • repository create / repository update: rename the flag to --default-branch-name. --default-branch still works as a hidden meow alias and now emits a deprecation warning pointing at the new name, so existing scripts keep functioning.
  • Updated help snapshots and bash completion. Added test coverage for the new error path, the deprecation warning, and the silent-path on the renamed flag.

Resolves ENG-4940.

Test plan

  • pnpm test:unit src/commands/scan/cmd-scan-create.test.mts src/commands/repository/cmd-repository-create.test.mts src/commands/repository/cmd-repository-update.test.mts — 43/43 pass (5 new cases)
  • pnpm run check:tsc — clean
  • Manual: socket scan create --default-branch=main ... now errors with a clear message
  • Manual: socket repository create fakerepo --default-branch=trunk ... works and emits deprecation warning
  • Manual: socket repository create --help shows --default-branch-name (old flag hidden from help)

`socket scan create --default-branch` is a boolean toggle, but meow
silently discards the value when users pass `--default-branch=<name>`
(a common mistake because `socket repository create --default-branch`
was a string flag that *did* accept a value). The scan is then created
without being marked as the default branch, so it never lands in the
Main/PR dashboard tabs.

- scan create: reject `--default-branch=<value>` with an InputError
  pointing users at the correct form (`--default-branch` on its own,
  with `--branch=<name>` to name the branch).
- repository create/update: rename the flag to `--default-branch-name`.
  `--default-branch` remains accepted as a hidden alias and now emits
  a deprecation warning pointing at the new name.

Includes updated help snapshots, new test coverage for the error path,
the deprecation warning, and the silent-path on the renamed flag.
@jdalton
Copy link
Copy Markdown
Contributor

Tackled in vNext as #1230. We can punt on v1.x 🕺

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.

2 participants