Skip to content

fix: derive paths-only branch from feature directory#3060

Open
luohui1 wants to merge 1 commit into
github:mainfrom
luohui1:fix/3026-paths-only-branch-fallback
Open

fix: derive paths-only branch from feature directory#3060
luohui1 wants to merge 1 commit into
github:mainfrom
luohui1:fix/3026-paths-only-branch-fallback

Conversation

@luohui1

@luohui1 luohui1 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #3026 by deriving the paths-only BRANCH value from the resolved feature directory basename when no explicit SPECIFY_FEATURE is available.

This keeps check-prerequisites --paths-only / -PathsOnly useful for feature-context invocations that rely on .specify/feature.json instead of an active feature branch environment variable.

Split out from #3053 after maintainer feedback to keep each bug fix in its own PR.

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest
  • Tested with a sample project (if applicable)

Additional validation run locally:

  • uv run --extra test pytest tests/test_check_prerequisites_paths_only.py -q - 4 passed, 5 skipped
  • uvx ruff check tests/test_check_prerequisites_paths_only.py - passed
  • git diff --check - passed

Manual test results

Agent: Codex (GPT-5) | OS/Shell: Windows 11 / PowerShell 7.5.4

Command tested Notes
.specify/scripts/powershell/check-prerequisites.ps1 -Json -PathsOnly Covered by regression test for non-empty BRANCH fallback from feature directory basename.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

This PR was implemented by Codex (GPT-5) acting as an AI coding agent on behalf of @luohui1. The agent read the repository contribution/security/code-of-conduct docs and issue templates, inspected the relevant code paths, implemented the changes, ran the validation listed above, and prepared this PR description.

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.

⚠️ Not ready to approve

The Bash fallback uses basename which won’t correctly derive a leaf name if feature_directory contains Windows-style backslashes, potentially producing an incorrect BRANCH value.

Pull request overview

This PR fixes check-prerequisites --paths-only / -PathsOnly emitting an empty BRANCH when SPECIFY_FEATURE is unset by deriving a fallback identifier from the resolved feature directory’s basename (supporting feature context coming from .specify/feature.json / SPECIFY_FEATURE_DIRECTORY).

Changes:

  • Bash: derive CURRENT_BRANCH from FEATURE_DIR basename when SPECIFY_FEATURE is not set.
  • PowerShell: derive CURRENT_BRANCH from FEATURE_DIR leaf name when SPECIFY_FEATURE is not set (trimming trailing separators first).
  • Add regression tests asserting BRANCH is non-empty (and equals the feature directory basename) for both Bash and PowerShell paths-only JSON output.
File summaries
File Description
scripts/bash/common.sh Adds fallback branch derivation from the resolved feature directory basename when explicit feature/branch state is absent.
scripts/powershell/common.ps1 Adds fallback branch derivation from the resolved feature directory leaf when explicit feature/branch state is absent.
tests/test_check_prerequisites_paths_only.py Adds regression tests for non-empty BRANCH fallback behavior in paths-only mode for Bash and PowerShell.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/bash/common.sh
Comment on lines +154 to +156
if [[ -z "$current_branch" ]]; then
current_branch="$(basename "$feature_dir")"
fi

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please address Copilot feedback. If not applicable, please explain why

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.

[Bug]: get_feature_paths emits empty CURRENT_BRANCH when SPECIFY_FEATURE unset, despite feature context via SPECIFY_FEATURE_DIRECTORY/feature.json

3 participants