feat(scripts): add --dry-run flag to create-new-feature#1998
feat(scripts): add --dry-run flag to create-new-feature#1998rhuss wants to merge 7 commits intogithub:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a --dry-run / -DryRun mode to the create-new-feature scripts so external tooling can compute the next branch/spec identifiers (and optionally JSON output) without performing the normal creation workflow.
Changes:
- Bash: add
--dry-run, skip branch/feature dir/spec file creation when active, and add optionalDRY_RUNto JSON output. - PowerShell: add
-DryRunwith equivalent behavior and JSON shaping. - Tests: add a
TestDryRunsuite covering dry-run naming and side-effect expectations (bash).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| scripts/bash/create-new-feature.sh | Adds --dry-run, gates creation steps, and conditionally emits DRY_RUN in JSON output. |
| scripts/powershell/create-new-feature.ps1 | Adds -DryRun, mirrors bash dry-run logic, and conditionally emits DRY_RUN in JSON output. |
| tests/test_timestamp_branches.py | Adds dry-run test coverage for naming, JSON field presence/absence, and lack of branch/feature-dir side effects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mnriem
left a comment
There was a problem hiding this comment.
Please address Copilot feedback. If not applicable, please explain why
Dry-run was unconditionally creating the root specs/ directory via mkdir -p / New-Item before the dry-run guard. This violated the documented contract of zero side effects. Also adds returncode assertion on git branch --list in tests and adds PowerShell dry-run test coverage (skipped when pwsh unavailable). Addresses review comments on github#1998. Assisted-By: 🤖 Claude Code
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add a --dry-run / -DryRun flag to both bash and PowerShell create-new-feature scripts that computes the next branch name, spec file path, and feature number without creating any branches, directories, or files. This enables external tools to query the next available name before running the full specify workflow. When combined with --json, the output includes a DRY_RUN field. Without --dry-run, behavior is completely unchanged. Closes github#1931 Assisted-By: 🤖 Claude Code
Dry-run was unconditionally creating the root specs/ directory via mkdir -p / New-Item before the dry-run guard. This violated the documented contract of zero side effects. Also adds returncode assertion on git branch --list in tests and adds PowerShell dry-run test coverage (skipped when pwsh unavailable). Addresses review comments on github#1998. Assisted-By: 🤖 Claude Code
- Gate `mkdir -p $SPECS_DIR` behind DRY_RUN check (bash + PowerShell) so dry-run creates zero directories - Add returncode assertion on `git branch --list` in test - Strengthen spec dir test to verify root `specs/` is not created - Add PowerShell dry-run test class (5 tests, skipped without pwsh) - Fix run_ps_script to use temp repo copy instead of project root Assisted-By: 🤖 Claude Code
Dry-run now queries remote branches via `git ls-remote --heads` (read-only, no fetch) to account for remote-only branches when computing the next sequential number. This prevents dry-run from returning a number that already exists on a remote. Added test verifying dry-run sees remote-only higher-numbered branches and adjusts numbering accordingly. Assisted-By: 🤖 Claude Code
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extract shared _extract_highest_number helper (bash) and Get-HighestNumberFromNames (PowerShell) to eliminate duplicated number extraction patterns between local branch and remote ref scanning. Add SkipFetch/skip_fetch parameter to check_existing_branches / Get-NextBranchNumber so dry-run reuses the same function instead of inlining duplicate max-of-branches-and-specs logic. Assisted-By: 🤖 Claude Code
Move remote.git and second_clone directories under git_repo instead of git_repo.parent to prevent path collisions with parallel test workers. Assisted-By: 🤖 Claude Code
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Set GIT_TERMINAL_PROMPT=0 for git ls-remote calls to prevent credential prompts from blocking dry-run in automation scenarios - Add returncode assertion to test_dry_run_with_timestamp git branch --list check Assisted-By: 🤖 Claude Code
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
--dry-run/-DryRunflag to both bash and PowerShellcreate-new-featurescriptsgit ls-remote --heads(read-only) for accurate numbering without mutating local state. This contrasts with the normal (non-dry-run) path which runsgit fetch --all --pruneto update local remote-tracking refs.DRY_RUNfield when flag is active; omitted otherwise (backwards compatible)Closes #1931. Also addresses aspects of #1680, #841, and #1921.
Changes
scripts/bash/create-new-feature.sh--dry-runflag, gate branch/dir creation, addDRY_RUNto JSON, add_extract_highest_numbershared helper, addget_highest_from_remote_refsusinggit ls-remote, addskip_fetchparam tocheck_existing_branchesscripts/powershell/create-new-feature.ps1-DryRunswitch, mirror bash logic, addGet-HighestNumberFromNamesshared helper, addGet-HighestNumberFromRemoteRefs, add-SkipFetchparam toGet-NextBranchNumbertests/test_timestamp_branches.pyTestDryRunclass (12 tests including remote branch awareness), addTestPowerShellDryRunclass (5 tests, skipped without pwsh)Remote branch handling
--dry-run)git fetch --all --prunethengit branch -a--dry-rungit ls-remote --headsper remote, plusgit branch -aBoth modes produce the same numbering result given the same remote state. The difference is that dry-run never modifies
.git/refs/remotes/.Test plan
--dry-run --jsonoutputs correct name with zero side effectsBackwards compatibility
--dry-run, behavior is 100% unchanged--dry-runis not used (no new fields)🤖 Generated with Claude Code