From 7dd83f150ab2e4a2771d3d991dff9446cfd90229 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sat, 4 Oct 2025 23:58:47 +0800 Subject: [PATCH] fix: Use commit SHA as version for development builds instead of 'latest' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Problem**: - version.json showed "version": "latest" for dev builds - Non-descriptive and not useful for version tracking **Solution**: - Use "dev-{commit_sha}" format for development builds - Stable releases: "3.4.1" (from tag) - Development builds: "dev-4ec1a17" (from commit SHA) - API failure fallback: "dev-unknown" **Version Format Examples**: ```json // Stable release {"version": "3.4.1", "commit_sha": "4ec1a17"} // Development build {"version": "dev-4ec1a17", "commit_sha": "4ec1a17"} ``` **Benefits**: - Clear distinction between stable and dev versions - version field always contains meaningful information - No more "latest" placeholder values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- install-remote.ps1 | 41 +++++++++++++++++++++-------------------- install-remote.sh | 29 ++++++++++++++++------------- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/install-remote.ps1 b/install-remote.ps1 index 2c8652cc..26eb272e 100644 --- a/install-remote.ps1 +++ b/install-remote.ps1 @@ -564,27 +564,8 @@ function Main { throw "Extraction failed" } - # Determine version and branch information to pass - $versionToPass = "" + # Get commit SHA from the downloaded repository first $commitSha = "" - - if ($Tag) { - # Specific tag version - $versionToPass = $Tag -replace '^v', '' # Remove 'v' prefix - } elseif ($Version -eq "stable") { - # Auto-detected latest stable - $latestTag = Get-LatestRelease - if ($latestTag) { - $versionToPass = $latestTag -replace '^v', '' - } else { - $versionToPass = "latest" - } - } else { - # Latest development or branch - $versionToPass = "latest" - } - - # Get commit SHA from the downloaded repository try { Push-Location $repoDir $commitSha = (git rev-parse --short HEAD 2>$null) @@ -602,6 +583,26 @@ function Main { $commitSha = "unknown" } + # Determine version and branch information to pass + $versionToPass = "" + + if ($Tag) { + # Specific tag version + $versionToPass = $Tag -replace '^v', '' # Remove 'v' prefix + } elseif ($Version -eq "stable") { + # Auto-detected latest stable + $latestTag = Get-LatestRelease + if ($latestTag) { + $versionToPass = $latestTag -replace '^v', '' + } else { + # Fallback: use commit SHA as version + $versionToPass = "dev-$commitSha" + } + } else { + # Latest development or branch - use commit SHA as version + $versionToPass = "dev-$commitSha" + } + $branchToPass = if ($Version -eq "branch") { $Branch } elseif ($Version -eq "latest") { "main" } elseif ($Tag) { $Tag } else { "main" } Write-ColorOutput "Version info: $versionToPass (branch: $branchToPass, commit: $commitSha)" $ColorInfo diff --git a/install-remote.sh b/install-remote.sh index 7895b7ab..2024322b 100644 --- a/install-remote.sh +++ b/install-remote.sh @@ -648,10 +648,21 @@ function main() { if [ $extract_status -eq 0 ] && [ -n "$repo_dir" ] && [ -d "$repo_dir" ]; then write_color "Extraction successful: $repo_dir" "$COLOR_SUCCESS" + # Get commit SHA from the downloaded repository first + local commit_sha="" + if command -v git &> /dev/null && [ -d "$repo_dir/.git" ]; then + commit_sha=$(cd "$repo_dir" && git rev-parse --short HEAD 2>/dev/null || echo "unknown") + else + # Fallback: try to get from GitHub API + local temp_branch="main" + [ "$VERSION_TYPE" = "branch" ] && temp_branch="$BRANCH" + commit_sha=$(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/$temp_branch" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7) + [ -z "$commit_sha" ] && commit_sha="unknown" + fi + # Determine version and branch information to pass local version_to_pass="" local branch_to_pass="" - local commit_sha="" if [ -n "$TAG_VERSION" ]; then # Specific tag version - remove 'v' prefix @@ -663,11 +674,12 @@ function main() { if [ -n "$latest_tag" ]; then version_to_pass="${latest_tag#v}" else - version_to_pass="latest" + # Fallback: use commit SHA as version + version_to_pass="dev-$commit_sha" fi else - # Latest development or branch - version_to_pass="latest" + # Latest development or branch - use commit SHA as version + version_to_pass="dev-$commit_sha" fi if [ "$VERSION_TYPE" = "branch" ]; then @@ -680,15 +692,6 @@ function main() { branch_to_pass="main" fi - # Get commit SHA from the downloaded repository - if command -v git &> /dev/null && [ -d "$repo_dir/.git" ]; then - commit_sha=$(cd "$repo_dir" && git rev-parse --short HEAD 2>/dev/null || echo "unknown") - else - # Fallback: try to get from GitHub API - commit_sha=$(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/$branch_to_pass" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7) - [ -z "$commit_sha" ] && commit_sha="unknown" - fi - write_color "Version info: $version_to_pass (branch: $branch_to_pass, commit: $commit_sha)" "$COLOR_INFO" # Run local installer with version information