Skip to content

Commit

Permalink
feat: allow for specifying pre-release
Browse files Browse the repository at this point in the history
This will allow the use of pre-release specific regex

Signed-off-by: Spazzy <brendankamp757@gmail.com>
  • Loading branch information
Spazzy757 committed Nov 20, 2024
1 parent 3da5a3d commit 87f7575
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions USERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ Currently, the following organizations are **officially** using Argo CD:
1. [Universidad Mesoamericana](https://www.umes.edu.gt/)
1. [Upsider Inc.](https://up-sider.com/lp/)
1. [Urbantz](https://urbantz.com/)
1. [Vandebron](https://www.vandebron.nl/)
1. [Vectra](https://www.vectra.ai)
1. [Veepee](https://www.veepee.com)
1. [Verkada](https://www.verkada.com)
Expand Down
14 changes: 14 additions & 0 deletions util/git/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,14 @@ func (m *nativeGitClient) resolveSemverRevision(revision string, refs []*plumbin
return ""
}

// check for if prerelease
pre := ""
if strings.Contains(revision, "-") {
parts := strings.Split(revision, "-")
revision = parts[0]
pre = parts[1]
}

maxVersion := semver.New(0, 0, 0, "", "")
maxVersionHash := plumbing.ZeroHash
for _, ref := range refs {
Expand All @@ -719,6 +727,12 @@ func (m *nativeGitClient) resolveSemverRevision(revision string, refs []*plumbin
continue
}

// If we are specifically looking for pre-releases
// we should skip any versions that are not pre-releases
if version.Prerelease() != pre && pre != "0" {
continue
}

if constraint.Check(version) {
if version.GreaterThan(maxVersion) {
maxVersion = version
Expand Down
5 changes: 5 additions & 0 deletions util/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ func TestLsRemote(t *testing.T) {
revision: ">=v2.9.0 <2.10.4", // it should resolve to v2.10.3
expectedCommit: "0fd6344537eb948cff602824a1d060421ceff40e",
},
{
name: "should resolve to a pre-release tag with semantic versioning",
revision: "v2.13.*-rc3", // it should resolve to v2.13.0-rc3
expectedCommit: "ec60abd4d810a2070930be09a4754ca73dd8be18",
},
{
name: "should resolve a star range tag with semantic versioning",
revision: "*",
Expand Down

0 comments on commit 87f7575

Please sign in to comment.