Skip to content

Conversation

@Capella87
Copy link
Contributor

@Capella87 Capella87 commented Sep 17, 2025

Add gitlab property to checkver and Scoop manifest schema.

Description

This PR adds checkver support for GitLab or GitLab self-hosted services with parsing atom feed of releases in that services with the predefined Regex or customized Regex.

If the value of checkver is gitlab and homepage URL is starting with https://gitlab.com, it will make use of the homepage value as a URL to retrieve data.
Or, checkver contains gitlab property with URL from GitLab or GitLab self-hosted services, it will utilize the value to do the same thing.

Motivation and Context

Currently as of September 2025, About 10 manifests in main bucket are parsing checkver from GitLab. Including other buckets, more manifests refer the GitLab URL to check the version information.

Also, I remember that someone made an issue for this topic.
(Closes #5508 )

That's why I made this PR.

How Has This Been Tested?

Manifests which contains GitLab or GitLab Self-Hosted Services in checkver are used in the testing.
Each URL must contain maintainer and repository name separated by slash, then change the property to gitlab.
Then I ran checkver.ps1 to check the new version with -f switch to get the version forcibly to see whether the changes are working well.

Tested Environment information retrieved from $PSVersionTable:

Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Other areas are not affected at all, But to use this feature, we need to add a new definition gitlab on checkver property in the schema.
Also, manifests containing GitLab would be updated after the release of future version.

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.

Summary by CodeRabbit

  • New Features

    • Added GitLab support to automatic version checking, matching existing GitHub behavior.
    • You can now specify a GitLab URL in checkver settings to fetch releases and detect versions.
    • Schema updated to accept a gitlab configuration alongside github.
  • Documentation

    • CHANGELOG updated to note GitLab support in checkver.

@coderabbitai
Copy link

coderabbitai bot commented Sep 17, 2025

Walkthrough

Adds GitLab support to checkver: updates bin/checkver.ps1 to handle GitLab release feeds and a default regex, extends schema.json with a checkver.gitlab field, and documents the feature in CHANGELOG.md. No public API signatures changed; GitLab homepage validation was added.

Changes

Cohort / File(s) Summary of Changes
Documentation
CHANGELOG.md
Added an Unreleased "Features" entry: “checkver: Add GitLab to checkver ([#5508])”.
checkver logic (GitLab support)
bin/checkver.ps1
Added GitLab handling: introduced gitlabRegex (default `/-/releases/(?:v
Schema extension
schema.json
Added definitions.checkver.properties.gitlab with { "format": "uri", "type": "string" } to allow specifying a GitLab URL in checkver.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant M as Manifest (json)
  participant CV as bin/checkver.ps1
  participant GL as GitLab Releases (Atom)
  participant RX as Regex Match

  Note over M,CV: New GitLab flow
  M->>CV: checkver == "gitlab"  or  checkver.gitlab = "<repo URL>"
  alt checkver == "gitlab"
    CV->>CV: ensure homepage starts with "https://gitlab.com/"
    CV->>CV: feed = homepage.TrimEnd('/') + "/-/releases?format=atom"
  else checkver.gitlab set
    CV->>CV: feed = gitlab.TrimEnd('/') + "/-/releases?format=atom"
  end
  CV->>GL: GET feed (Atom)
  GL-->>CV: Atom XML
  CV->>RX: apply default regex /\-\/releases\/(?:v|V)?([\d.]+)/
  RX-->>CV: extract version
  CV-->>M: return detected version
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble at feeds where new tags hide,
GitLab steps into the meadow with pride.
Atom hums softly, regex sniffs the trail,
Schemas and changelogs stamp the new tale.
A rabbit hops onward—checkver's set to compile. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat(checkver): Add gitlab support to checkver" is concise, follows conventional-commit style, and accurately summarizes the primary change (adding native GitLab support to checkver) reflected in the changeset.
Linked Issues Check ✅ Passed Based on the provided changes, this PR satisfies the main objectives of [#5508]: it implements a 'gitlab' checkver type (bin/checkver.ps1), adds a gitlab field to the schema (schema.json), supplies a default releases Atom feed and a default regex so maintainers generally do not need custom regexes, and supports both gitlab.com (via homepage validation) and self-hosted instances (via json.checkver.gitlab), while allowing custom regex/URLs to cover nonstandard paths.
Out of Scope Changes Check ✅ Passed All modified files (bin/checkver.ps1, schema.json, and CHANGELOG.md) are directly related to adding GitLab support and the accompanying schema/documentation update, and I see no unrelated or out-of-scope changes introduced by this PR.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c7aba3 and 781b2fa.

📒 Files selected for processing (2)
  • bin/checkver.ps1 (1 hunks)
  • schema.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • bin/checkver.ps1
  • schema.json

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
CHANGELOG.md (1)

10-13: Tweak wording for consistency with prior entries.

Consider “checkver: Add GitLab support” (mirrors existing style like “GitHub predefined hashes support”).

-**checkver**: Add GitLab to `checkver` ([#5508](https://github.com/ScoopInstaller/Scoop/issues/5508))
+**checkver:** Add GitLab support ([#5508](https://github.com/ScoopInstaller/Scoop/issues/5508))
bin/checkver.ps1 (2)

172-174: Fix typo and clarify error message.

“checkvar” -> “checkver”; clarify requirement.

-        if (!$json.homepage.StartsWith('https://gitlab.com/')) {
-            error "$name checkvar expects the homepage to be a GitLab"
-        }
+        if (!$json.homepage.StartsWith('https://gitlab.com/')) {
+            error "$name checkver expects the homepage to start with 'https://gitlab.com/'"
+        }

165-171: Optional: broaden default regex to include pre-release/build suffixes.

Current ([\d.]+) misses tags like v1.2.3-beta.1. If desired, align with a semver-ish capture.

-    } else {
-        $gitlabRegex = '/-/releases/(?:v|V)?([\d.]+)'
-    }
+    } else {
+        $gitlabRegex = '/-/releases/(?:v|V)?([0-9]+(?:\.[0-9]+)*(?:[-+][0-9A-Za-z.-]+)?)'
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04b7ce7 and 9505676.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • bin/checkver.ps1 (1 hunks)
  • schema.json (1 hunks)
🔇 Additional comments (1)
bin/checkver.ps1 (1)

178-181: LGTM: custom GitLab endpoint path.

Using /-/releases?format=atom with a provided GitLab (including self-hosted) URL is sensible. Regex reuse is correct.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
bin/checkver.ps1 (1)

171-177: Fix: use homepage when checkver is the string gitlab (and improve error text).

Accessing $json.checkver.gitlab when $json.checkver -eq 'gitlab' (a string) will throw. Mirror the GitHub branch: build from homepage. Also make the error message explicit.

-    if ($json.checkver -eq 'gitlab') {
-        if (!$json.homepage.StartsWith('https://gitlab.com/')) {
-            error "$name checkver expects the homepage to be a GitLab"
-        }
-        $url = $json.checkver.gitlab.TrimEnd('/') + '/-/releases?format=atom'
-        $regex = $gitlabRegex
-    }
+    if ($json.checkver -eq 'gitlab') {
+        if (!$json.homepage -or !$json.homepage.StartsWith('https://gitlab.com/')) {
+            error "$name checkver expects the homepage to start with 'https://gitlab.com/'"
+        }
+        $url = $json.homepage.TrimEnd('/') + '/-/releases?format=atom'
+        $regex = $gitlabRegex
+    }

Run to confirm no remaining string-typed property dereferences:

#!/bin/bash
rg -n -C2 --type=powershell $'\$json\.checkver\s*-eq\s*\'gitlab\'' bin/checkver.ps1
rg -n -C2 --type=powershell $'\$json\.checkver\.gitlab' bin/checkver.ps1
🧹 Nitpick comments (1)
bin/checkver.ps1 (1)

165-170: Broaden default GitLab regex to match tags as well as releases (and richer semver).

Many GitLab projects publish tags without Releases. Matching both improves coverage and aligns with the stated objective of tag-based version checks.

-    if ($regex) {
-        $gitlabRegex = $regex
-    } else {
-        $gitlabRegex = '/-/releases/(?:v|V)?([\d.]+)'
-    }
+    if ($regex) {
+        $gitlabRegex = $regex
+    } else {
+        # Match either /-/releases/<ver> or /-/tags/<ver>; capture common semver forms
+        $gitlabRegex = '/-/(?:releases|tags)/(?:v|V)?(?<version>\d+(?:\.\d+)+(?:[-._][0-9A-Za-z]+)*)'
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9505676 and 8c7aba3.

📒 Files selected for processing (1)
  • bin/checkver.ps1 (1 hunks)
🔇 Additional comments (1)
bin/checkver.ps1 (1)

178-181: Accept prebuilt GitLab feed/collection URLs (avoid double-appending /-/releases?format=atom)

Verified the proposed conditional logic against common inputs — it produces the expected URLs.

File: bin/checkver.ps1 (around lines 178–181)

-    if ($json.checkver.gitlab) {
-        $url = $json.checkver.gitlab.TrimEnd('/') + '/-/releases?format=atom'
-        $regex = $gitlabRegex
-    }
+    if ($json.checkver.gitlab) {
+        $base = $json.checkver.gitlab.TrimEnd('/')
+        if ($base -match '\?format=atom$') {
+            $url = $base
+        } elseif ($base -match '/-/(releases|tags)$') {
+            $url = $base + '?format=atom'
+        } else {
+            $url = $base + '/-/releases?format=atom'
+        }
+        $regex = $gitlabRegex
+    }

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.

1 participant