MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / IsHigherVersion

Function IsHigherVersion

dgraphtest/image.go:316–338  ·  view source on GitHub ↗

IsHigherVersion checks whether "higher" is the higher version compared to "lower"

(higher, lower string)

Source from the content-addressed store, hash-verified

314
315// IsHigherVersion checks whether "higher" is the higher version compared to "lower"
316func IsHigherVersion(higher, lower string) (bool, error) {
317 // the order of if conditions matters here
318 if lower == localVersion {
319 return false, nil
320 }
321 if higher == localVersion {
322 return true, nil
323 }
324
325 // An older commit is usually the ancestor of a newer commit which is a descendant commit
326 cmd := exec.Command("git", "merge-base", "--is-ancestor", lower, higher)
327 cmd.Dir = repoDir
328 if out, err := cmd.CombinedOutput(); err != nil {
329 if exitError, ok := err.(*exec.ExitError); ok && exitError.ExitCode() == 1 {
330 return false, nil
331 }
332
333 return false, errors.Wrapf(err, "error checking if [%v] is ancestor of [%v]\noutput:%v",
334 higher, lower, string(out))
335 }
336
337 return true, nil
338}
339
340func fixGoModIfNeeded() error {
341 repoModFilePath := filepath.Join(repoDir, "go.mod")

Callers 8

TestDeleteNamespaceMethod · 0.92
populateClusterFunction · 0.92
populateClusterFunction · 0.92
setupBeforeClusterMethod · 0.70
ShouldSkipTestFunction · 0.70

Calls

no outgoing calls

Tested by 6

TestDeleteNamespaceMethod · 0.74
populateClusterFunction · 0.74
populateClusterFunction · 0.74