Skip to content

Fix CRAN package version validation to allow more than 4 version components (#36813)#36821

Merged
wxiaoguang merged 1 commit intogo-gitea:release/v1.25from
GiteaBot:backport-36813-v1.25
Mar 4, 2026
Merged

Fix CRAN package version validation to allow more than 4 version components (#36813)#36821
wxiaoguang merged 1 commit intogo-gitea:release/v1.25from
GiteaBot:backport-36813-v1.25

Conversation

@GiteaBot
Copy link
Collaborator

@GiteaBot GiteaBot commented Mar 3, 2026

Backport #36813 by @Copilot

R packages like RcppEigen use versions with 5+ components (e.g., 0.3.4.0.2), which were rejected with "package version is invalid" due to an overly restrictive regex.

R's numeric_version spec imposes no upper bound on version components, so the {1,3} quantifier (limiting to 4 total components) was incorrect.

Changes

  • modules/packages/cran/metadata.go: Relax version regex from {1,3} to +, accepting any number of dot/dash-separated integer components ≥ 2:
    - versionPattern = regexp.MustCompile(`\A[0-9]+(?:[.\-][0-9]+){1,3}\z`)
    + versionPattern = regexp.MustCompile(`\A[0-9]+(?:[.\-][0-9]+)+\z`)
  • modules/packages/cran/metadata_test.go: Remove 1.2.3.4.5 / 1-2-3-4-5 from the invalid-version list; add ValidVersionManyComponents test covering 0.3.4.0.2, 1.2.3.4.5, and 1-2-3-4-5.
Original prompt

This section details on the original issue you should resolve

<issue_title>Problem upload R Packages into Gitea CRAN repo</issue_title>
<issue_description>### Description

When trying to upload a R package downloaded from the official CRAN repository :

https://cran.r-project.org/web/packages/RcppEigen/index.html

with the official curl method presented on the Gitea official website :

curl --user [user]:[password] --upload-file ./Packages/RcppEigen/RcppEigen_0.3.4.0.2.tar.gz [my_gitea_instance]/api/packages/[organization]/cran/src

it leads to the following error :

package version is invalid400

For many other packages, it works perfectly.

Gitea Version

1.22.4

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

package version is invalid400

Screenshots

No response

Git Version

No response

Operating System

Ubuntu 22.04.1 LTS

How are you running Gitea?

I have a managed Gitea instance deployed on a VM Ubuntu 22.04.1 LTS with snap method
I try to import the package from the same VM where my Gitea instance is deployed

Database

None</issue_description>

<agent_instructions>Open a PR by the suggested fix and add a test for this case.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…onents (go-gitea#36813)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
@GiteaBot GiteaBot added modifies/go Pull requests that update Go code type/bug labels Mar 3, 2026
@GiteaBot GiteaBot requested a review from TheFox0x7 March 3, 2026 19:23
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 3, 2026
@GiteaBot GiteaBot added this to the 1.25.5 milestone Mar 3, 2026
@GiteaBot GiteaBot requested a review from wxiaoguang March 3, 2026 19:23
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 3, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 3, 2026
@wxiaoguang wxiaoguang merged commit 0f55eff into go-gitea:release/v1.25 Mar 4, 2026
32 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants