Skip to content

feat: allow version substitution beyond autoupdate.url - #6755

Closed
idleberg wants to merge 5 commits into
ScoopInstaller:masterfrom
idleberg:feat/manifest-version-variables
Closed

idleberg wants to merge 5 commits into
ScoopInstaller:masterfrom
idleberg:feat/manifest-version-variables

Conversation

@idleberg

@idleberg idleberg commented Sep 24, 2026 •

Copy link
Copy Markdown

Description

Scoop currently supports version substitution for autoupdate.url. In my opinion it also valuable for other fields. Consider the abbreviated manifest:

{
    "homepage": "https://github.com/idleberg/my-app",
    "version": "1.2.3",
    "url": "https://github.com/idleberg/my-app/releases/download/v1.2.3/my-app-1.2.3-windows.zip",
    "autoupdate": {
        "url": "https://github.com/idleberg/dent-desktop/releases/download/v$version/my-app-$version-windows.zip"
    }
}

The version is specified at three places. Allowing the use of version substitution, editing a manifest is less prone to errors. So a manifest would only specify the version once:

{
    "homepage": "https://github.com/idleberg/my-app",
    "version": "1.2.3",
    "url": "https://github.com/idleberg/my-app/releases/download/v$version/my-app-$version-windows.zip",
    "autoupdate": {
        "url": "https://github.com/idleberg/dent-desktop/releases/download/v$version/my-app-$version-windows.zip"
    }
}

Motivation and Context

It solves a personal problem, dealing with such matters is difficult for a neurodivergent person. Others might appreciate it to.

I have written PowerShell before and used an agent for assistance. I read all the code and made edits, the changes seems reasonable. If using AI is a deal-breaker, I understand – hence the full disclosure.

How Has This Been Tested?

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

RetriggerView in GreptileConfidence Score: 2/5

Fix the missing download expansion, single-entry array changes, and stale mixed properties before merging.

Findings

  1. P1 Downloads still use literal templates ▶
  2. P1 Single-entry arrays lose their shape ▶
  3. P1 Updates can mix release versions ▶

Summary

Adds version-variable expansion to manifest reads and URL checks. Autoupdate keeps template fields and hashes their expanded URLs.

  • Manifest fields can use version tokens beyond autoupdate URLs.
  • Autoupdate leaves version-based manifest fields as reusable templates.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Raw manifest] --> B[Get-Manifest]
    B --> C[Expand version variables]
    C --> D[Install]
    A --> E[manifest or parse_json]
    E --> F[Update or pinned download]
    F --> G[Literal template URL]
    A --> H[Autoupdate]
    H --> I[Keep properties containing templates]
    I --> J[Literal siblings remain unchanged]
Loading

Reviews (1) · Last reviewed commit: "Merge commit 'e6aa3b36' into feat/manife..." · Reviewed by Greptile

@idleberg
idleberg marked this pull request as ready for review September 24, 2026 14:58
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Summary by CodeRabbit

  • New Features
    • Version variables are expanded in supported manifest properties, including download URLs and architecture-specific values.
    • URL validation and download hash checks use resolved values, so manifests with version placeholders can be checked.
    • Automatic manifest updates retain version templates in applicable properties while calculating hashes from the appropriate download URL.
    • Scripts, lifecycle settings, and other excluded properties remain unchanged during manifest expansion.

Walkthrough

Manifest access and URL validation scripts now expand version variables in eligible manifest properties. Auto-update logic detects version templates, selects URLs for hash calculation, and preserves templated values during updates.

Changes

Manifest version variables

Layer / File(s) Summary
Version substitutions and manifest expansion
lib/core.ps1, lib/manifest.ps1
Get-VersionSubstitution builds version-derived values. Manifest access functions use Expand-ManifestVariable to expand eligible properties, including architecture values, while preserving excluded properties. User manifest generation requests raw templates.
Auto-update template handling
lib/autoupdate.ps1, test/Scoop-Manifest.Tests.ps1
Test-VersionTemplate detects templated values. Hash updates use the manifest URL when it contains a version template; otherwise, they use the autoupdate URL. Templated properties remain unchanged. Tests cover expansion, hash URL selection, and raw-template handling.
Expanded URLs in validation scripts
bin/checkhashes.ps1, bin/checkurls.ps1
URL collection uses expanded manifest values. Hash verification continues to read expected hashes from the raw manifest.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to b3672

Manifests using the new main-URL template cannot pass bucket validation. Update the schema before merging.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: extending version substitution beyond autoupdate.url.
Description check ✅ Passed The description explains the motivation, shows the intended manifest change, and identifies the related tests and implementation scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 6443d388-3880-4973-9c02-bbbd232f41c4

📥 Commits

Reviewing files that changed from the base of the PR and between b588a06 and f9fc23c.

📒 Files selected for processing (6)
  • bin/checkhashes.ps1
  • bin/checkurls.ps1
  • lib/autoupdate.ps1
  • lib/core.ps1
  • lib/manifest.ps1
  • test/Scoop-Manifest.Tests.ps1

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread lib/autoupdate.ps1 Resolved
Comment thread lib/manifest.ps1 Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Pass checkver custom matches to Test-VersionTemplate. · autoupdate.ps1:496-500

lib/autoupdate.ps1:496-500
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Pass checkver custom matches to Test-VersionTemplate.

bin/checkver.ps1 passes named matches to Invoke-AutoUpdate, but Test-VersionTemplate builds substitutions without those matches. A raw $match<Key> token therefore remains unchanged, so AutoUpdate can replace the raw property or URL with the concrete autoupdate value instead of preserving the template. Pass the existing substitution table to the detector.

Suggested fix
-                    $urlSource = if (Test-VersionTemplate $Manifest.url $Version) { $Manifest.url } else { $Manifest.autoupdate.url }
+                    $urlSource = if (Test-VersionTemplate $Manifest.url $Version $Substitutions) { $Manifest.url } else { $Manifest.autoupdate.url }
...
-                        $urlSource = if (Test-VersionTemplate $Manifest.architecture.$arch.url $Version) { $Manifest.architecture.$arch.url } else { arch_specific 'url' $Manifest.autoupdate $arch }
+                        $urlSource = if (Test-VersionTemplate $Manifest.architecture.$arch.url $Version $Substitutions) { $Manifest.architecture.$arch.url } else { arch_specific 'url' $Manifest.autoupdate $arch }
...
-                if (Test-VersionTemplate $Manifest.$currentProperty $Version) { continue }
+                if (Test-VersionTemplate $Manifest.$currentProperty $Version $Substitutions) { continue }
...
-                    if ($Manifest.architecture.$arch.$currentProperty -and ($Manifest.autoupdate.architecture.$arch.$currentProperty -or $Manifest.autoupdate.$currentProperty) -and !(Test-VersionTemplate $Manifest.architecture.$arch.$currentProperty $Version)) {
+                    if ($Manifest.architecture.$arch.$currentProperty -and ($Manifest.autoupdate.architecture.$arch.$currentProperty -or $Manifest.autoupdate.$currentProperty) -and !(Test-VersionTemplate $Manifest.architecture.$arch.$currentProperty $Version $Substitutions)) {
...
-function Test-VersionTemplate($Value, [String] $Version) {
-    $substitutions = Get-VersionSubstitution $Version
-    (ConvertTo-Json -InputObject (substitute $Value $substitutions) -Depth 5 -Compress) -ne (ConvertTo-Json -InputObject $Value -Depth 5 -Compress)
+function Test-VersionTemplate($Value, [String] $Version, [Hashtable] $Substitutions) {
+    if ($null -eq $Substitutions) {
+        $Substitutions = Get-VersionSubstitution $Version
+    }
+    (ConvertTo-Json -InputObject (substitute $Value $Substitutions) -Depth 5 -Compress) -ne (ConvertTo-Json -InputObject $Value -Depth 5 -Compress)
 }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5e7d6877-19e5-4689-b57a-052591801332

📥 Commits

Reviewing files that changed from the base of the PR and between f9fc23c and b34425c.

📒 Files selected for processing (3)
  • lib/autoupdate.ps1
  • lib/manifest.ps1
  • test/Scoop-Manifest.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/Scoop-Manifest.Tests.ps1
  • lib/autoupdate.ps1

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread lib/manifest.ps1 Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Allow version templates in main URLs. · manifest.ps1:120-136

lib/manifest.ps1:120-136
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Allow version templates in main URLs.

schema.json rejects $ in the main url definition. The import-bucket validator parses each manifest file directly and validates it before Get-Manifest expands $version. Manifests using the new URL template therefore fail the supported validation workflow.

Remove the dollar-sign rejection from both uriOrArrayOfUris branches.

Suggested fix
                 "format": "uri",
-                "not": {
-                    "pattern": "(\\$)"
-                },
                 "type": "string"
...
                         "format": "uri",
-                        "not": {
-                            "pattern": "(\\$)"
-                        },
                         "type": "string"

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: c281b2c1-ac83-4614-bc81-e7a08ce5df06

📥 Commits

Reviewing files that changed from the base of the PR and between b34425c and b367294.

📒 Files selected for processing (2)
  • lib/manifest.ps1
  • test/Scoop-Manifest.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/Scoop-Manifest.Tests.ps1
  • lib/manifest.ps1

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@niheaven

Copy link
Copy Markdown
Member

The actual download URL is autoupdate by checkver and autoupdate.url here.

@idleberg

idleberg commented Oct 7, 2026

Copy link
Copy Markdown
Author

Update: Back from vacation, I will try and update the PR this weekend

# Conflicts:
#	lib/manifest.ps1
#	test/Scoop-Manifest.Tests.ps1
Comment thread lib/manifest.ps1
}
}

if (!$Raw) { $manifest = Expand-ManifestVariable $manifest }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Downloads still use literal templates

Get-Manifest expands version templates, but scoop update reads through manifest instead. Its download step requests the literal $version URL, so an app that installs with the new syntax cannot update. Version-pinned scoop download also reads generated manifests with parse_json, although this PR now preserves their URL templates. Expand manifests on these download paths too, while keeping autoupdate inputs raw.

Comment thread lib/manifest.ps1
$_.Value = $_.Value.PSObject.Copy()
$_.Value.PSObject.Properties | ForEach-Object { $_.Value = Expand-ManifestVariable $_.Value $substitutions }
} else {
$_.Value = substitute $_.Value $substitutions

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Single-entry arrays lose their shape

Applying substitute to every field changes single-entry nested arrays even without variables. For example, shortcuts: [["app.exe", "App"]] becomes ["app.exe", "App"]. The shortcut code then treats each string as a separate shortcut rather than one target/name pair. Single-entry bin aliases and persist mappings have the same problem.

This also makes Test-VersionTemplate mistake a one-item literal URL array for a template, leaving its old URL during autoupdate. Preserve array boundaries during expansion and template checks.

Comment thread lib/autoupdate.ps1
} elseif ($Manifest.$currentProperty -and $Manifest.autoupdate.$currentProperty) {
# Update other property (global)
# Templated properties are expanded on read, keep them as-is
if (Test-VersionTemplate $Manifest.$currentProperty $Version) { continue }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Updates can mix release versions

Finding one template skips the entire property, including literal siblings that still need autoupdate. Given url: ["https://example.com/app-$version.zip", "https://example.com/helper-1.0.zip"], updating to 2.0 leaves the helper at 1.0 even when autoupdate.url supplies helper-$version.zip. The new hash branch then hashes that old helper too, so the manifest can silently install files from two releases. Preserve templates per array entry or object field, and update the remaining values from autoupdate.

@idleberg idleberg closed this Nov 15, 2026
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.

2 participants