Skip to content

geogebra: Update checkver script#17052

Merged
z-Fng merged 2 commits into
ScoopInstaller:masterfrom
SorYoshino:geogebra
Jan 22, 2026
Merged

geogebra: Update checkver script#17052
z-Fng merged 2 commits into
ScoopInstaller:masterfrom
SorYoshino:geogebra

Conversation

@SorYoshino

@SorYoshino SorYoshino commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactors the checkver script for geogebra to improve maintainability and detection accuracy by tracking official download redirects.

Related issues or pull requests

Changes

  • Optimize checkver script:
    • Replaced the HTML scraping logic (previously tied to the /6.0/ directory) with a dynamic HEAD request to the generic suite entry point (/package/win-suite).
    • Implemented HttpClient with AllowAutoRedirect = $true to resolve the final download URL.
    • Added logic to extract the version string directly from the resolved filename in the AbsoluteUri.
    • Included a compatibility check for PowerShell 5.1 to ensure System.Net.Http is loaded correctly.

Notes

  • The previous checkver was prone to failure when the major/minor version changed (e.g., moving from 5.2 to 5.4). The new implementation is version-agnostic and relies on the official redirection service provided by GeoGebra.
  • Using a HEAD request instead of a full GET request (Invoke-WebRequest) is more efficient as it only retrieves metadata without downloading the entire page content.
  • Consistent Logic: This aligns the geogebra (v6) manifest with the updated logic applied to geogebra5.

Testing

The test results are as follows:
┏[ D:\Software\Scoop\Local\apps\scoop\current\bin][ develop ≡]
└─> .\checkver.ps1 -App geogebra -Dir 'D:\Temporary\Software\Microsoft\Windows Sandbox\Repositories\Scoop\Buckets\Extras\bucket' -f
geogebra: 6.0.913.0 (scoop version is 6.0.913.0)
Forcing autoupdate!
Autoupdating geogebra
DEBUG[1768857009] [$updatedProperties] = [url hash] -> D:\Software\Scoop\Local\apps\scoop\current\lib\autoupdate.ps1:500:5
DEBUG[1768857009] $substitutions (hashtable) -> D:\Software\Scoop\Local\apps\scoop\current\lib\autoupdate.ps1:230:5
DEBUG[1768857009] $substitutions.$match1                        6.0.913.0
DEBUG[1768857009] $substitutions.$basenameNoExt                 GeoGebra-Windows-Portable-6-0-913-0
DEBUG[1768857009] $substitutions.$buildVersion                  0
DEBUG[1768857009] $substitutions.$baseurl                       https://download.geogebra.org/installers/6.0
DEBUG[1768857009] $substitutions.$patchVersion                  913
DEBUG[1768857009] $substitutions.$dashVersion                   6-0-913-0
DEBUG[1768857009] $substitutions.$majorVersion                  6
DEBUG[1768857009] $substitutions.$dotVersion                    6.0.913.0
DEBUG[1768857009] $substitutions.$url                           https://download.geogebra.org/installers/6.0/GeoGebra-Windows-Portable-6-0-913-0.zip
DEBUG[1768857009] $substitutions.$underscoreVersion             6_0_913_0
DEBUG[1768857009] $substitutions.$version                       6.0.913.0
DEBUG[1768857009] $substitutions.$cleanVersion                  609130
DEBUG[1768857009] $substitutions.$matchHead                     6.0.913
DEBUG[1768857009] $substitutions.$matchTail                     .0
DEBUG[1768857009] $substitutions.$preReleaseVersion             6.0.913.0
DEBUG[1768857009] $substitutions.$minorVersion                  0
DEBUG[1768857009] $substitutions.$basename                      GeoGebra-Windows-Portable-6-0-913-0.zip
DEBUG[1768857009] $substitutions.$urlNoExt                      https://download.geogebra.org/installers/6.0/GeoGebra-Windows-Portable-6-0-913-0
DEBUG[1768857009] $hashfile_url = $null -> D:\Software\Scoop\Local\apps\scoop\current\lib\autoupdate.ps1:233:5
Downloading GeoGebra-Windows-Portable-6-0-913-0.zip to compute hashes!
Loading GeoGebra-Windows-Portable-6-0-913-0.zip from cache
Computed hash: 2f9ef7e2b9eff92451f6d203fbed086642d4bb0f540dc3b65686a4c0363cdae6
Writing updated geogebra manifest
  • Use conventional PR title: <manifest-name[@version]|chore>: <general summary of the pull request>
  • I have read the Contributing Guide

Summary by CodeRabbit

  • Chores
    • Simplified GeoGebra version-checking to be faster and more reliable by switching to a direct package URL check.
    • Improved retrieval reliability across environments via redirect-based version detection.
    • No change to public behavior: the latest version is still reported as before.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 19, 2026

Copy link
Copy Markdown

Walkthrough

Replaced HTML scraping in bucket/geogebra.json checkver with a HEAD request to the package entry URL that follows redirects, derives the package filename from the final URI, extracts the version via regex, and writes it to output.

Changes

Cohort / File(s) Change Summary
GeoGebra checkver refactor
bucket/geogebra.json
Removed name_filter/release_url/download_page/version_sort/name_list and href-based parsing. Added PowerShell guard for System.Net.Http, HttpClient with redirects enabled, HEAD request to package entry URL, extraction of final RequestUri, regex-based version derivation, and Write-Output of the version.

Sequence Diagram(s)

sequenceDiagram
  participant PS as PowerShell script
  participant Http as HttpClient (System.Net.Http)
  participant Remote as download.geogebra.org

  PS->>Http: Ensure System.Net.Http loaded (PS version guard)
  PS->>Http: Create HttpClient (AllowAutoRedirect = true)
  PS->>Http: SEND HEAD https://download.geogebra.org/package/win-suite
  Http->>Remote: HEAD request
  Remote-->>Http: 3xx redirect(s) -> final URI (package filename)
  Http-->>PS: Return final RequestUri
  PS->>PS: Extract package name from Uri, parse version (regex)
  PS-->>Console: Write-Output latest_version
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 I hopped through redirects, light and spry,

Followed the URI where filenames lie.
A regex nibble, a version found,
I wrote it out with a cheerful bound.
Carrots for commits, and hops abound.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'geogebra: Update checkver script' accurately describes the main change—refactoring the checkver script for the geogebra package.
Description check ✅ Passed The PR description includes a comprehensive summary, related issues, detailed changes, notes on improvements, testing results, and both required checklist items marked as complete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

All changes look good.

Wait for review from human collaborators.

geogebra

  • Lint
  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate

Check the full log for details.

@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

🤖 Fix all issues with AI agents
In `@bucket/geogebra.json`:
- Around line 56-65: The script creates disposable objects ($http_handler,
$client, $request, $response) but never disposes them; update the checkver code
to ensure these IDisposable objects are disposed (e.g., wrap the call to
$client.SendAsync($request).Result in a try/finally or use PowerShell's using
statement) so that $response.Dispose(), $request.Dispose(), $client.Dispose(),
and $http_handler.Dispose() are always called even on error; reference the
symbols $http_handler, $client, $request, and $response when implementing the
disposal.
🧹 Nitpick comments (1)
bucket/geogebra.json (1)

63-63: Consider simplifying the regex for extracting the filename.

The regex .+(?<=/)([^/]+)$ works but is unnecessarily complex. A simpler alternative would be more readable.

♻️ Simpler alternative
-            "$package_name = $response.RequestMessage.RequestUri.AbsoluteUri -replace '.+(?<=/)([^/]+)$', '$1'",
+            "$package_name = $response.RequestMessage.RequestUri.Segments[-1]",

Or if you prefer to keep the regex approach:

-            "$package_name = $response.RequestMessage.RequestUri.AbsoluteUri -replace '.+(?<=/)([^/]+)$', '$1'",
+            "$package_name = $response.RequestMessage.RequestUri.AbsoluteUri -replace '^.+/', ''",

Comment thread bucket/geogebra.json Outdated
@SorYoshino

Copy link
Copy Markdown
Contributor Author

/verify

@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

🤖 Fix all issues with AI agents
In `@bucket/geogebra.json`:
- Around line 62-65: The code currently disposes $response, $request, $client,
and $http_handler before reading $response.RequestMessage.RequestUri which can
cause ObjectDisposedException and also never disposes if SendAsync throws;
update the flow in the routine that calls $client.SendAsync($request).Result so
you first call SendAsync and extract $package_name/$latest_version from
$response.RequestMessage.RequestUri (using the existing regex logic), then move
the disposal of $response, $request, $client, $http_handler into a finally block
to ensure they are always disposed after extraction; ensure extraction happens
before disposal and that exceptions still trigger disposal in the finally.

Comment thread bucket/geogebra.json Outdated
@github-actions

Copy link
Copy Markdown
Contributor

All changes look good.

Wait for review from human collaborators.

geogebra

  • Lint
  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate

Check the full log for details.

@SorYoshino

Copy link
Copy Markdown
Contributor Author

/verify

@github-actions

Copy link
Copy Markdown
Contributor

All changes look good.

Wait for review from human collaborators.

geogebra

  • Lint
  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate

Check the full log for details.

@haussmann

Copy link
Copy Markdown
Contributor

Maybe it would be simpler to use this instead?
Invoke-WebRequest -Uri 'https://download.geogebra.org/package/win-suite' -Method Head -MaximumRedirection 0

The result contains:

$res.Headers.Location
/installers/6.0/suite/GeoGebraCalculator-Windows-Installer-6-0-913-0.exe

@SorYoshino

Copy link
Copy Markdown
Contributor Author

Maybe it would be simpler to use this instead?

In PowerShell 5.x, Invoke-WebRequest uses the Internet Explorer engine by default to parse web pages. Without the -UseBasicParsing parameter, user interaction or confirmation may be required.

┏[ ~]
└─> $response = Invoke-WebRequest -Uri 'https://download.geogebra.org/package/win-suite' -Method Head -MaximumRedirection 0

Security Warning: Script Execution Risk
Invoke-WebRequest parses the content of the web page. Script code in the web page might be run when the page is parsed.
      RECOMMENDED ACTION:
      Use the -UseBasicParsing switch to avoid script code execution.

      Do you want to continue?

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):

┏[ ~]
└─> $response = Invoke-WebRequest -Uri 'https://download.geogebra.org/package/win-suite' -Method Head -MaximumRedirection 0 -UseBasicParsing
Invoke-WebRequest : The maximum redirection count has been exceeded. To increase the number of redirections allowed, supply a higher value to the
-MaximumRedirection parameter.
At line:1 char:13
+ $response = Invoke-WebRequest -Uri 'https://download.geogebra.org/pac ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], InvalidOperationException
    + FullyQualifiedErrorId : MaximumRedirectExceeded,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

In PowerShell 7.x, Invoke-WebRequest cannot function properly without the -SkipHttpErrorCheck parameter. In addition, in both 5.x and 7.x, omitting -ErrorAction SilentlyContinue will result in errors being thrown.

┏[ ~]
└─> $response = Invoke-WebRequest -Uri 'https://download.geogebra.org/package/win-suite' -Method Head -MaximumRedirection 0
Invoke-WebRequest: Response status code does not indicate success: 302 (Moved Temporarily).

┏[ ~]
└─> $response = Invoke-WebRequest -Uri 'https://download.geogebra.org/package/win-suite' -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck
Invoke-WebRequest: The maximum redirection count has been exceeded. To increase the number of redirections allowed, supply a higher value to the -MaximumRedirection parameter.

HttpClient automatically follows all 301/302 redirects until it reaches the final .exe file. By contrast, since Invoke-WebRequest is used with -MaximumRedirection 0, it stops immediately upon encountering a redirect and throws an exception. If multiple redirects are involved, the code must be implemented as a loop to handle them correctly.


Code simplicity alone should not be the sole objective. General applicability and stability must also be taken into consideration.

@z-Fng

z-Fng commented Jan 20, 2026

Copy link
Copy Markdown
Member

o-l-a-v proposed a common solution, though I'm not sure if it works for GeoGebra.

[System.Net.HttpWebRequest]::Create(
    '<url>'
).GetResponse().ResponseUri.AbsoluteUri

e.g.,

"checkver": {
"script": [
"$request = [System.Net.HttpWebRequest]::Create('https://www.strem.io/download?platform=windows&four=true')",
"$response = $request.GetResponse()",
"Write-Output $response.ResponseUri.AbsoluteUri"
],
"regex": "shell-win/v(?<version>[\\d.]+)/Stremio\\+\\k<version>\\.exe"
},

I've been considering replacing the original approach for retrieving redirect links in Extras bucket. e.g.,

"script": [
"$url = 'https://www.foxmail.com/win/download'",
"if ($PSVersionTable.PSVersion.Major -lt 7.0) {",
" $req = Invoke-WebRequest -Uri $url -MaximumRedirection 0 -ErrorAction SilentlyContinue",
"} else {",
" $req = Invoke-WebRequest -Uri $url -MaximumRedirection 0 -ErrorAction SilentlyContinue -SkipHttpErrorCheck",
"}",

@SorYoshino

Copy link
Copy Markdown
Contributor Author

o-l-a-v proposed a common solution

HttpWebRequest has performance limitations and is considered outdated; Microsoft no longer recommends using it for new development.

I've been considering replacing the original approach for retrieving redirect links in Extras bucket. e.g.,

HttpClient automatically follows all 301/302 redirects until it reaches the final .exe file. By contrast, since Invoke-WebRequest is used with -MaximumRedirection 0, it stops immediately upon encountering a redirect and throws an exception. If multiple redirects are involved, the code must be implemented as a loop to handle them correctly.


By checking the PowerShell major version and conditionally executing Add-Type -AssemblyName System.Net.Http, it is possible to ensure that HttpClient-related code runs correctly on both PowerShell 5.x and 7.x.

Even without this logic, the manifest can still be successfully updated to the latest version in a PowerShell 7.x environment.

Therefore, I believe that the more performant and modern HttpClient should be used.

@SorYoshino

Copy link
Copy Markdown
Contributor Author

/verify

@github-actions

Copy link
Copy Markdown
Contributor

All changes look good.

Wait for review from human collaborators.

geogebra

  • Lint
  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate

Check the full log for details.

@z-Fng

z-Fng commented Jan 20, 2026

Copy link
Copy Markdown
Member

HttpWebRequest has performance limitations and is considered outdated; Microsoft no longer recommends using it for new development.

succeeded 18 minutes ago in 2m 58s

Our workflow takes only 2-3 minutes to check versions for 2000+ packages, so I don't think we need to worry about the performance overhead of HttpWebRequest vs HttpClient. Considering Scoop-Core still uses Net.WebClient for version detection, the fact that HttpWebRequest is outdated isn't really a concern. Simplicity and maintainability are more important here.

That's why I'm in favor of o-l-a-v's proposal to replace everything with a unified solution and finally move it into Scoop-Core.

@SorYoshino

Copy link
Copy Markdown
Contributor Author

Our workflow takes only 2-3 minutes to check versions for 2000+ packages, so I don't think we need to worry about the performance overhead of HttpWebRequest vs HttpClient. Considering Scoop-Core still uses Net.WebClient for version detection, the fact that HttpWebRequest is outdated isn't really a concern. Simplicity and maintainability are more important here.

That's why I'm in favor of o-l-a-v's proposal to replace everything with a unified solution and finally move it into Scoop-Core.

I also support integrating this functionality into Scoop Core. Whether HttpWebRequest or HttpClient is used at that point is not a concern for me, as this should be a decision made collectively by the maintainers.

While I personally prefer adopting more modern technologies, I recognize that not everyone shares this view, which is entirely reasonable. Please advise whether HttpWebRequest or Invoke-WebRequest should be used in this PR, and I will update the relevant implementation accordingly.

@z-Fng

z-Fng commented Jan 22, 2026

Copy link
Copy Markdown
Member

Thanks for understanding!

Please advise whether HttpWebRequest or Invoke-WebRequest should be used in this PR, and I will update the relevant implementation accordingly.

I'd vote for using HttpWebRequest.

@SorYoshino SorYoshino marked this pull request as draft January 22, 2026 19:09
@SorYoshino

Copy link
Copy Markdown
Contributor Author

/verify

@github-actions

Copy link
Copy Markdown
Contributor

All changes look good.

Wait for review from human collaborators.

geogebra

  • Lint
  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate

Check the full log for details.

@SorYoshino SorYoshino marked this pull request as ready for review January 22, 2026 19:17
@SorYoshino

Copy link
Copy Markdown
Contributor Author

I'd vote for using HttpWebRequest.

Done.

@z-Fng

z-Fng commented Jan 22, 2026

Copy link
Copy Markdown
Member

/verify

@github-actions

Copy link
Copy Markdown
Contributor

All changes look good.

Wait for review from human collaborators.

geogebra

  • Lint
  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate

Check the full log for details.

@z-Fng z-Fng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your contribution!

@z-Fng z-Fng merged commit 5a2f324 into ScoopInstaller:master Jan 22, 2026
3 checks passed
@SorYoshino SorYoshino deleted the geogebra branch January 22, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants