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

Function IsHigherVersion

dgraphapi/cluster.go:786–808  ·  view source on GitHub ↗

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

(higher, lower, repoDir string)

Source from the content-addressed store, hash-verified

784
785// IsHigherVersion checks whether "higher" is the higher version compared to "lower"
786func IsHigherVersion(higher, lower, repoDir string) (bool, error) {
787 // the order of if conditions matters here
788 if lower == localVersion {
789 return false, nil
790 }
791 if higher == localVersion {
792 return true, nil
793 }
794
795 // An older commit is usually the ancestor of a newer commit which is a descendant commit
796 cmd := exec.Command("git", "merge-base", "--is-ancestor", lower, higher)
797 cmd.Dir = repoDir
798 if out, err := cmd.CombinedOutput(); err != nil {
799 if exitError, ok := err.(*exec.ExitError); ok {
800 return exitError.ExitCode() == 0, nil
801 }
802
803 return false, errors.Wrapf(err, "error checking if [%v] is ancestor of [%v]\noutput:%v",
804 higher, lower, string(out))
805 }
806
807 return true, nil
808}
809
810func GetHttpClient(alphaUrl, zeroUrl string) (*HTTPClient, error) {
811 adminUrl := "http://" + alphaUrl + "/admin"

Callers 2

BackupMethod · 0.70
RestoreMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected