Skip to content

Commit

Permalink
add Version field
Browse files Browse the repository at this point in the history
  • Loading branch information
Tch1b0 committed Jul 28, 2023
1 parent b924ada commit ee9baca
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pkg/utility/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,6 +54,7 @@ func DependencyFromString(str string) Dependency {

return Dependency{
Identifier: identifier,
Version: version,
Url: url,
Type: t,
}
Expand Down

0 comments on commit ee9baca

Please sign in to comment.