-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Use golang.org/x/mod/semver for version parsing
- Loading branch information
Showing
7 changed files
with
46 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
package gitlab | ||
|
||
import ( | ||
"strings" | ||
|
||
"golang.org/x/mod/semver" | ||
) | ||
|
||
type GitLabVersion struct { | ||
Major int | ||
Minor int | ||
Patch int | ||
Suffix string | ||
Version string | ||
} | ||
|
||
func NewGitLabVersion(version string) GitLabVersion { | ||
ver := "" | ||
if strings.HasPrefix(version, "v") { | ||
ver = version | ||
} else if version != "" { | ||
ver = "v" + version | ||
} | ||
|
||
return GitLabVersion{Version: ver} | ||
} | ||
|
||
// PipelineJobsKeysetPaginationSupported returns true if the GitLab instance | ||
// is running 15.9 or later. | ||
func (v GitLabVersion) PipelineJobsKeysetPaginationSupported() bool { | ||
if v.Major == 0 { | ||
if v.Version == "" { | ||
return false | ||
} else if v.Major < 15 { | ||
return false | ||
} else if v.Major > 15 { | ||
return true | ||
} else { | ||
return v.Minor >= 9 | ||
} | ||
|
||
return semver.Compare(v.Version, "v15.9.0") >= 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters