IsHigherVersion checks whether "higher" is the higher version compared to "lower"
(higher, lower, repoDir string)
| 784 | |
| 785 | // IsHigherVersion checks whether "higher" is the higher version compared to "lower" |
| 786 | func 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 | |
| 810 | func GetHttpClient(alphaUrl, zeroUrl string) (*HTTPClient, error) { |
| 811 | adminUrl := "http://" + alphaUrl + "/admin" |