comment cleanup in update.ps1

This commit is contained in:
Kevin Woley
2025-02-20 21:41:03 -08:00
parent 6244dbc910
commit 7ba3db056a

View File

@@ -8,13 +8,13 @@
1. **Release mode (default):** 1. **Release mode (default):**
- Fetches the latest release info via GitHubs API. - Fetches the latest release info via GitHubs API.
- Compares the release tag (after normalization) against a locally stored version (in version.txt). - Compares the release tag (after normalization) against a locally stored version (in state.xml).
- If the GitHub release is newer, downloads the release zip, extracts it, copies the files - If the GitHub release is newer, downloads the release zip, extracts it, copies the files
over the local installation. over the local installation.
2. **Branch mode:** 2. **Branch mode:**
- Targets a specific branch (default "main") by retrieving branch information from GitHub. - Targets a specific branch (default "main") by retrieving branch information from GitHub.
- Compares the latest commit SHA on that branch against a locally stored SHA. - Compares the latest commit SHA on that branch against a locally stored SHA (in state.xml).
- If the remote commit SHA differs, downloads the branch zip archive, extracts it, - If the remote commit SHA differs, downloads the branch zip archive, extracts it,
copies the files over the local installation. copies the files over the local installation.
@@ -92,7 +92,6 @@ function Get-ModifiedFiles {
[string]$DateTime [string]$DateTime
) )
## FIXME: IS THERE A BETTER WAY TO INIT A LIST?
$modifiedFiles = New-Object System.Collections.Generic.List[System.Object] $modifiedFiles = New-Object System.Collections.Generic.List[System.Object]
if(-not (Test-Path $Source)) { if(-not (Test-Path $Source)) {
@@ -229,7 +228,7 @@ if ($Mode -eq "release") {
# Read the version of the scripts installed # Read the version of the scripts installed
$localVersion = $Script:ResticStateInstalledVersion $localVersion = $Script:ResticStateInstalledVersion
if ([string]::IsNullOrEmpty($localVersion)) { if ([string]::IsNullOrEmpty($localVersion)) {
# Write-Host "No version information stored locally." # No version information stored locally
$localVersion = "0.0.0" $localVersion = "0.0.0"
} }
@@ -245,17 +244,16 @@ if ($Mode -eq "release") {
$latestTagRaw = $release.tag_name $latestTagRaw = $release.tag_name
$latestTag = $latestTagRaw.Trim() $latestTag = $latestTagRaw.Trim()
# Write-Host "Latest GitHub release version: $latestTag"
# Normalize versions (remove leading "v" if present) # Normalize versions (remove leading "v" if present)
function Normalize-Version($versionString) { function Get-NormalizedVersion($versionString) {
if ($versionString.StartsWith("v", [System.StringComparison]::InvariantCultureIgnoreCase)) { if ($versionString.StartsWith("v", [System.StringComparison]::InvariantCultureIgnoreCase)) {
return $versionString.Substring(1) return $versionString.Substring(1)
} }
return $versionString return $versionString
} }
$normalizedLocalVersion = Normalize-Version $localVersion $normalizedLocalVersion = Get-NormalizedVersion $localVersion
$normalizedLatestVersion = Normalize-Version $latestTag $normalizedLatestVersion = Get-NormalizedVersion $latestTag
try { try {
$localVersionObj = [Version]$normalizedLocalVersion $localVersionObj = [Version]$normalizedLocalVersion
@@ -309,7 +307,6 @@ elseif ($Mode -eq "branch") {
} }
$latestCommitSHA = $branchInfo.commit.sha $latestCommitSHA = $branchInfo.commit.sha
# Write-Host "Latest commit on $repoOwner/$repoName branch '$BranchName': $latestCommitSHA"
if ($localCommitSHA -eq $latestCommitSHA) { if ($localCommitSHA -eq $latestCommitSHA) {
Write-Host "Installed commit ($latestCommitSHA) is up-to-date. No update needed." Write-Host "Installed commit ($latestCommitSHA) is up-to-date. No update needed."