git-codereview: remove use of Mergeable
Mergeable has been removed from the Gerrit API -
it was too expensive to maintain, had racy semantics,
and was too little used.
As of right now, git submit fails because it doesn't see
"mergeable":true in the JSON.
Remove the use of it in git-codereview.
Change-Id: I12c821b9dbc44183a689d510dd20104eab5a0043
Reviewed-on: https://go-review.googlesource.com/c/review/+/222937
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
diff --git a/git-codereview/api.go b/git-codereview/api.go
index a3375ea..c7126f9 100644
--- a/git-codereview/api.go
+++ b/git-codereview/api.go
@@ -368,7 +368,6 @@
Status string
Created string
Updated string
- Mergeable bool
Insertions int
Deletions int
Number int `json:"_number"`
diff --git a/git-codereview/submit.go b/git-codereview/submit.go
index 19d38e3..bff713d 100644
--- a/git-codereview/submit.go
+++ b/git-codereview/submit.go
@@ -106,12 +106,6 @@
}
}
- // Don't bother if the server can't merge the changes.
- if !g.Mergeable {
- // Server cannot merge; explicit sync is needed.
- dief("cannot submit: conflicting changes submitted, run 'git sync'")
- }
-
if *noRun {
printf("stopped before submit")
return g
diff --git a/git-codereview/submit_test.go b/git-codereview/submit_test.go
index 127d7d3..3f893ec 100644
--- a/git-codereview/submit_test.go
+++ b/git-codereview/submit_test.go
@@ -91,14 +91,8 @@
testRan(t) // nothing
testPrintedStderr(t, "cannot submit: change has Code-Review rejection")
- t.Logf("> unmergeable")
- srv.setJSON(id, `{"status": "NEW", "mergeable": false, "labels": {"Code-Review": {"approved": {}}}}`)
- testMainDied(t, "submit")
- testRan(t, "git push -q origin HEAD:refs/for/master")
- testPrintedStderr(t, "cannot submit: conflicting changes submitted, run 'git sync'")
-
t.Logf("> submit with unexpected status")
- const newJSON = `{"status": "NEW", "mergeable": true, "labels": {"Code-Review": {"approved": {}}}}`
+ const newJSON = `{"status": "NEW", "labels": {"Code-Review": {"approved": {}}}}`
srv.setJSON(id, newJSON)
srv.setReply("/a/changes/proj~master~I123456789/submit", gerritReply{body: ")]}'\n" + newJSON})
testMainDied(t, "submit")
@@ -232,13 +226,11 @@
cl1 := GerritChange{
Status: "NEW",
- Mergeable: true,
CurrentRevision: hash1,
Labels: map[string]*GerritLabel{"Code-Review": &GerritLabel{Approved: new(GerritAccount)}},
}
cl2 := GerritChange{
Status: "NEW",
- Mergeable: false,
CurrentRevision: hash2,
Labels: map[string]*GerritLabel{"Code-Review": &GerritLabel{Approved: new(GerritAccount)}},
}
@@ -251,14 +243,13 @@
return gerritReply{status: 409}
}
cl1.Status = "MERGED"
- cl2.Mergeable = true
return gerritReply{json: cl1}
}})
srv.setReply("/a/changes/proj~master~I0000002", gerritReply{f: func() gerritReply {
return gerritReply{json: cl2}
}})
srv.setReply("/a/changes/proj~master~I0000002/submit", gerritReply{f: func() gerritReply {
- if cl2.Status != "NEW" || !cl2.Mergeable {
+ if cl2.Status != "NEW" {
return gerritReply{status: 409}
}
cl2.Status = "MERGED"