本文整理汇总了Golang中github.com/Masterminds/glide/cfg.Dependency.Reference方法的典型用法代码示例。如果您正苦于以下问题:Golang Dependency.Reference方法的具体用法?Golang Dependency.Reference怎么用?Golang Dependency.Reference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Masterminds/glide/cfg.Dependency
的用法示例。
在下文中一共展示了Dependency.Reference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getWizard
func getWizard(dep *cfg.Dependency) {
var remote string
if dep.Repository != "" {
remote = dep.Repository
} else {
remote = "https://" + dep.Name
}
// Lookup dependency info and store in cache.
msg.Info("--> Gathering release information for %s", dep.Name)
wizardFindVersions(dep)
memlatest := cache.MemLatest(remote)
if memlatest != "" {
dres := wizardAskLatest(memlatest, dep)
if dres {
dep.Reference = memlatest
sv, err := semver.NewVersion(dep.Reference)
if err == nil {
res := wizardAskRange(sv, dep)
if res == "m" {
dep.Reference = "^" + sv.String()
} else if res == "p" {
dep.Reference = "~" + sv.String()
}
}
}
}
}
示例2: determineDependency
func determineDependency(v, dep *cfg.Dependency, dest string) *cfg.Dependency {
repo, err := v.GetRepo(dest)
if err != nil {
singleWarn("Unable to access repo for %s\n", v.Name)
singleInfo("Keeping %s %s", v.Name, v.Reference)
return v
}
vIsRef := repo.IsReference(v.Reference)
depIsRef := repo.IsReference(dep.Reference)
// Both are references and they are different ones.
if vIsRef && depIsRef {
singleWarn("Conflict: %s ref is %s, but also asked for %s\n", v.Name, v.Reference, dep.Reference)
singleInfo("Keeping %s %s", v.Name, v.Reference)
return v
} else if vIsRef {
// The current one is a reference and the suggestion is a SemVer constraint.
con, err := semver.NewConstraint(dep.Reference)
if err != nil {
singleWarn("Version issue for %s: '%s' is neither a reference or semantic version constraint\n", dep.Name, dep.Reference)
singleInfo("Keeping %s %s", v.Name, v.Reference)
return v
}
ver, err := semver.NewVersion(v.Reference)
if err != nil {
// The existing version is not a semantic version.
singleWarn("Conflict: %s version is %s, but also asked for %s\n", v.Name, v.Reference, dep.Reference)
singleInfo("Keeping %s %s", v.Name, v.Reference)
return v
}
if con.Check(ver) {
singleInfo("Keeping %s %s because it fits constraint '%s'", v.Name, v.Reference, dep.Reference)
return v
}
singleWarn("Conflict: %s version is %s but does not meet constraint '%s'\n", v.Name, v.Reference, dep.Reference)
singleInfo("Keeping %s %s", v.Name, v.Reference)
return v
} else if depIsRef {
con, err := semver.NewConstraint(v.Reference)
if err != nil {
singleWarn("Version issue for %s: '%s' is neither a reference or semantic version constraint\n", v.Name, v.Reference)
singleInfo("Keeping %s %s", v.Name, v.Reference)
return v
}
ver, err := semver.NewVersion(dep.Reference)
if err != nil {
singleWarn("Conflict: %s version is %s, but also asked for %s\n", v.Name, v.Reference, dep.Reference)
singleInfo("Keeping %s %s", v.Name, v.Reference)
return v
}
if con.Check(ver) {
v.Reference = dep.Reference
singleInfo("Using %s %s because it fits constraint '%s'", v.Name, v.Reference, v.Reference)
return v
}
singleWarn("Conflict: %s semantic version constraint is %s but '%s' does not meet the constraint\n", v.Name, v.Reference, v.Reference)
singleInfo("Keeping %s %s", v.Name, v.Reference)
return v
}
// Neither is a vcs reference and both could be semantic version
// constraints that are different.
_, err = semver.NewConstraint(dep.Reference)
if err != nil {
// dd.Reference is not a reference or a valid constraint.
singleWarn("Version %s %s is not a reference or valid semantic version constraint\n", dep.Name, dep.Reference)
singleInfo("Keeping %s %s", v.Name, v.Reference)
return v
}
_, err = semver.NewConstraint(v.Reference)
if err != nil {
// existing.Reference is not a reference or a valid constraint.
// We really should never end up here.
singleWarn("Version %s %s is not a reference or valid semantic version constraint\n", v.Name, v.Reference)
v.Reference = dep.Reference
v.Pin = ""
singleInfo("Using %s %s because it is a valid version", v.Name, v.Reference)
return v
}
// Both versions are constraints. Try to merge them.
// If either comparison has an || skip merging. That's complicated.
ddor := strings.Index(dep.Reference, "||")
eor := strings.Index(v.Reference, "||")
if ddor == -1 && eor == -1 {
// Add the comparisons together.
newRef := v.Reference + ", " + dep.Reference
v.Reference = newRef
v.Pin = ""
singleInfo("Combining %s semantic version constraints %s and %s", v.Name, v.Reference, dep.Reference)
return v
}
//.........这里部分代码省略.........