diff --git a/extensions/git/README.md b/extensions/git/README.md index a6986dee3..16ab478e9 100644 --- a/extensions/git/README.md +++ b/extensions/git/README.md @@ -37,8 +37,8 @@ branch_numbering: sequential ## Installation ```bash -# Install from the bundled extension -specify extension add git --from extensions/git/ +# Install from the bundled extension directory +specify extension add extensions/git --dev # Or it auto-installs during specify init (migration period) ``` diff --git a/extensions/git/scripts/bash/create-new-feature.sh b/extensions/git/scripts/bash/create-new-feature.sh index 584b33e61..32e98d109 100644 --- a/extensions/git/scripts/bash/create-new-feature.sh +++ b/extensions/git/scripts/bash/create-new-feature.sh @@ -209,6 +209,15 @@ if [ "$_common_loaded" != "true" ]; then exit 1 fi +# If only git-common.sh was loaded, verify that the required helpers +# (resolve_template, json_escape) are available. These are provided by the +# core common.sh; git-common.sh only supplies has_git / check_feature_branch. +if ! type resolve_template >/dev/null 2>&1 || ! type json_escape >/dev/null 2>&1; then + echo "Error: resolve_template/json_escape not defined. The core common.sh is required but could not be located." >&2 + echo "Tried: \$SCRIPT_DIR/common.sh, .specify/scripts/bash/common.sh, scripts/bash/common.sh" >&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 diff --git a/extensions/git/scripts/powershell/create-new-feature.ps1 b/extensions/git/scripts/powershell/create-new-feature.ps1 index a2cd6ee02..7fe5ef5e5 100644 --- a/extensions/git/scripts/powershell/create-new-feature.ps1 +++ b/extensions/git/scripts/powershell/create-new-feature.ps1 @@ -179,6 +179,14 @@ if (-not $commonLoaded) { throw "Unable to locate common script file. Please ensure the Specify core scripts are installed." } +# If only git-common.ps1 was loaded, verify that Resolve-Template is available. +# Resolve-Template is provided by the core common.ps1; git-common.ps1 only +# supplies Test-HasGit / Test-FeatureBranch. +if (-not (Get-Command Resolve-Template -ErrorAction SilentlyContinue)) { + throw ("Resolve-Template not defined. The core common.ps1 is required but could not be located. " + + "Tried: $PSScriptRoot/common.ps1, .specify/scripts/powershell/common.ps1, scripts/powershell/common.ps1") +} + try { $repoRoot = git rev-parse --show-toplevel 2>$null if ($LASTEXITCODE -eq 0) { diff --git a/src/specify_cli/__init__.py b/src/specify_cli/__init__.py index d8e408297..cb1a4495c 100644 --- a/src/specify_cli/__init__.py +++ b/src/specify_cli/__init__.py @@ -1188,7 +1188,8 @@ def _install_bundled_git_extension(project_path: Path) -> bool: Before 1.0.0, this auto-install will be removed and the extension will become opt-in. - Returns True if the extension was installed, False otherwise. + Returns True if the extension was installed or already present, + False otherwise. """ ext_source = _locate_bundled_git_extension() if ext_source is None: @@ -1205,8 +1206,14 @@ def _install_bundled_git_extension(project_path: Path) -> bool: speckit_ver = get_speckit_version() manager.install_from_directory(ext_source, speckit_ver) return True - except Exception: - # Non-fatal: branching still works via core scripts during migration + except Exception as exc: + # Non-fatal: branching still works via core scripts during migration, + # but log a warning so users can tell the auto-install did not happen. + console.print( + "[dim yellow]Warning: failed to auto-install bundled git extension; " + "branching via the git extension may be unavailable. " + f"Details: {exc}[/dim yellow]" + ) return False diff --git a/templates/commands/specify.md b/templates/commands/specify.md index 36e0c1a2e..ec52c00e5 100644 --- a/templates/commands/specify.md +++ b/templates/commands/specify.md @@ -88,8 +88,8 @@ Given that feature description, do this: - `mkdir -p "$FEATURE_DIR"` - `touch "$SPEC_FILE"` - PowerShell: - - `New-Item -ItemType Directory -Path $env:FEATURE_DIR -Force | Out-Null` - - `New-Item -ItemType File -Path $env:SPEC_FILE -Force | Out-Null` + - `New-Item -ItemType Directory -Path $FEATURE_DIR -Force | Out-Null` + - `New-Item -ItemType File -Path $SPEC_FILE -Force | Out-Null` - Then proceed directly to step 3 using `FEATURE_DIR` and `SPEC_FILE` - If the registry file does not exist, proceed with branch creation using the default behavior (backward compatibility)