From ee9bacadc8caf562e8cb8bc6f1c7fd8d7d0aa8f0 Mon Sep 17 00:00:00 2001 From: Tch1b0 Date: Fri, 28 Jul 2023 16:01:16 +0200 Subject: [PATCH] add `Version` field --- pkg/utility/dependency.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/utility/dependency.go b/pkg/utility/dependency.go index 2c2b745..117ea57 100644 --- a/pkg/utility/dependency.go +++ b/pkg/utility/dependency.go @@ -12,20 +12,31 @@ const ( ) type Dependency struct { - Identifier string `json:"identifier"` - Url string `json:"url"` - Type string `json:"type"` + Identifier string `json:"identifier"` + Version *string `json:"version"` + Url string `json:"url"` + Type string `json:"type"` } // create a new dependency struct from a string func DependencyFromString(str string) Dependency { // the (ideally) unique identifier of the dependency var identifier string + // the version of the dependency + var version *string = nil // the url used for accessing the dependency var url string // the type of the dependency, GithubAsset | GDAsset var t string + if strings.Contains(str, "@") { + tmp := strings.Split(str, "@") + v := tmp[len(tmp)-1] + version = &v + + str = strings.Replace(str, "@"+v, "", 1) + } + if isGithubUrl := IsGithubRepoUrl(str); isGithubUrl || IsUserAndRepo(str) { if isGithubUrl { url = str @@ -43,6 +54,7 @@ func DependencyFromString(str string) Dependency { return Dependency{ Identifier: identifier, + Version: version, Url: url, Type: t, }