mirror of
https://github.com/github/spec-kit.git
synced 2026-03-24 14:23:09 +00:00
fix: address all PR review comments for git extension
- Fix bash common.sh sourcing: check .specify/scripts/bash/ first, then scripts/bash/, with explicit error if neither found - Fix PowerShell common.ps1 sourcing: use $fallbackRoot for reliable path resolution, with explicit error if not found - Remove undocumented branch_template and auto_fetch from extension.yml defaults and config-template.yml (scripts don't use them yet) - Remove unused ExtensionError import in _install_bundled_git_extension - Remove undocumented SPECKIT_GIT_BRANCH_NUMBERING env var from README - Fix specify.md: skip step 2 when before_specify hook already executed - Fix specify.md: add explicit FEATURE_DIR/SPEC_FILE in disabled-git path - Fix specify.md: add PowerShell path to script resolution - Add tests for git extension auto-install during specify init Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/spec-kit/sessions/008835a0-7778-40bb-bdb2-4182b22be315
This commit is contained in:
committed by
GitHub
parent
312c37be25
commit
5e49ec6936
@@ -32,20 +32,6 @@ Configuration is stored in `.specify/extensions/git/git-config.yml`:
|
||||
```yaml
|
||||
# Branch numbering strategy: "sequential" or "timestamp"
|
||||
branch_numbering: sequential
|
||||
|
||||
# Branch name template
|
||||
branch_template: "{number}-{short_name}"
|
||||
|
||||
# Whether to fetch remotes before computing next branch number
|
||||
auto_fetch: true
|
||||
```
|
||||
|
||||
### Environment Variable Override
|
||||
|
||||
Set `SPECKIT_GIT_BRANCH_NUMBERING` to override the `branch_numbering` config value:
|
||||
|
||||
```bash
|
||||
export SPECKIT_GIT_BRANCH_NUMBERING=timestamp
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -3,10 +3,3 @@
|
||||
|
||||
# Branch numbering strategy: "sequential" (001, 002, ...) or "timestamp" (YYYYMMDD-HHMMSS)
|
||||
branch_numbering: sequential
|
||||
|
||||
# Branch name template (used with sequential numbering)
|
||||
# Available placeholders: {number}, {short_name}
|
||||
branch_template: "{number}-{short_name}"
|
||||
|
||||
# Whether to run `git fetch --all --prune` before computing the next branch number
|
||||
auto_fetch: true
|
||||
|
||||
@@ -45,5 +45,3 @@ tags:
|
||||
|
||||
defaults:
|
||||
branch_numbering: sequential
|
||||
branch_template: "{number}-{short_name}"
|
||||
auto_fetch: true
|
||||
|
||||
@@ -176,21 +176,39 @@ clean_branch_name() {
|
||||
# were initialised with --no-git.
|
||||
SCRIPT_DIR="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Source common.sh: try the core scripts directory first (standard layout),
|
||||
# then fall back to the extension's sibling copy.
|
||||
# Source common.sh using the following priority:
|
||||
# 1. common.sh next to this script (source checkout layout)
|
||||
# 2. .specify/scripts/bash/common.sh under the project root (installed project)
|
||||
# 3. scripts/bash/common.sh under the project root (source checkout fallback)
|
||||
# 4. git-common.sh next to this script (minimal fallback)
|
||||
_common_loaded=false
|
||||
|
||||
if [ -f "$SCRIPT_DIR/common.sh" ]; then
|
||||
source "$SCRIPT_DIR/common.sh"
|
||||
_common_loaded=true
|
||||
else
|
||||
# When running from an extension install (.specify/extensions/git/scripts/bash/),
|
||||
# resolve common.sh from the project's core scripts directory.
|
||||
_ext_repo_root="$(cd "$SCRIPT_DIR/../../../../.." 2>/dev/null && pwd)"
|
||||
if [ -f "$_ext_repo_root/scripts/bash/common.sh" ]; then
|
||||
source "$_ext_repo_root/scripts/bash/common.sh"
|
||||
# resolve to .specify/ (4 levels up), then to the project root (5 levels up).
|
||||
_dot_specify="$(cd "$SCRIPT_DIR/../../../.." 2>/dev/null && pwd)"
|
||||
_project_root="$(cd "$SCRIPT_DIR/../../../../.." 2>/dev/null && pwd)"
|
||||
|
||||
if [ -n "$_dot_specify" ] && [ -f "$_dot_specify/scripts/bash/common.sh" ]; then
|
||||
source "$_dot_specify/scripts/bash/common.sh"
|
||||
_common_loaded=true
|
||||
elif [ -n "$_project_root" ] && [ -f "$_project_root/scripts/bash/common.sh" ]; then
|
||||
source "$_project_root/scripts/bash/common.sh"
|
||||
_common_loaded=true
|
||||
elif [ -f "$SCRIPT_DIR/git-common.sh" ]; then
|
||||
source "$SCRIPT_DIR/git-common.sh"
|
||||
_common_loaded=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$_common_loaded" != "true" ]; then
|
||||
echo "Error: Could not locate common.sh or git-common.sh. Please ensure the Specify core scripts are installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if git rev-parse --show-toplevel >/dev/null 2>&1; then
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
HAS_GIT=true
|
||||
|
||||
@@ -146,20 +146,37 @@ if (-not $fallbackRoot) {
|
||||
}
|
||||
|
||||
# Load common functions (includes Resolve-Template).
|
||||
# Try the core scripts directory first (standard layout), then fall back
|
||||
# to the extension's sibling copy.
|
||||
# Search locations in priority order:
|
||||
# 1. common.ps1 next to this script (source checkout layout)
|
||||
# 2. .specify/scripts/powershell/common.ps1 under the project root (installed project)
|
||||
# 3. scripts/powershell/common.ps1 under the project root (source checkout fallback)
|
||||
# 4. git-common.ps1 next to this script (minimal fallback)
|
||||
$commonLoaded = $false
|
||||
|
||||
if (Test-Path "$PSScriptRoot/common.ps1") {
|
||||
. "$PSScriptRoot/common.ps1"
|
||||
$commonLoaded = $true
|
||||
} else {
|
||||
# When running from an extension install (.specify/extensions/git/scripts/powershell/),
|
||||
# resolve common.ps1 from the project's core scripts directory.
|
||||
$extRepoRoot = (Resolve-Path (Join-Path $PSScriptRoot "../../../../..") -ErrorAction SilentlyContinue)
|
||||
$coreCommon = if ($extRepoRoot) { Join-Path $extRepoRoot "scripts/powershell/common.ps1" } else { "" }
|
||||
if ($coreCommon -and (Test-Path $coreCommon)) {
|
||||
. $coreCommon
|
||||
} elseif (Test-Path "$PSScriptRoot/git-common.ps1") {
|
||||
. "$PSScriptRoot/git-common.ps1"
|
||||
$coreCommonCandidates = @()
|
||||
|
||||
if ($fallbackRoot) {
|
||||
$coreCommonCandidates += (Join-Path $fallbackRoot ".specify/scripts/powershell/common.ps1")
|
||||
$coreCommonCandidates += (Join-Path $fallbackRoot "scripts/powershell/common.ps1")
|
||||
}
|
||||
|
||||
$coreCommonCandidates += "$PSScriptRoot/git-common.ps1"
|
||||
|
||||
foreach ($candidate in $coreCommonCandidates) {
|
||||
if ($candidate -and (Test-Path $candidate)) {
|
||||
. $candidate
|
||||
$commonLoaded = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $commonLoaded) {
|
||||
throw "Unable to locate common script file. Please ensure the Specify core scripts are installed."
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user