For errors on refs/publish/..., warn about too old git-review

While we removed support for magic `refs/publish/...` branches some
time ago, there are still lots of git-review users in the wild that use
an old git-review that relies on `refs/publish/...` (i.e.: git-review
before 1.27). Their git-review fails with error messages like:

 remote: error: branch refs/publish/master:
 remote: use a SHA1 visible to you, or get update permission on the ref
 remote: User: <redacted>
 remote: Contact an administrator to fix the permissions

and

 remote: error: branch refs/publish/master:
 remote: You need 'Create' rights to create new references.
 remote: User: <redacted>
 remote: Contact an administrator to fix the permissions

which are of little use for them.

Since old git-review versions are still so popular with users, we add a
hint towards upgrading their git-review, upon errors on
`refs/publish/...`. So error messages for users of a too old git-review
now look like

  remote: error: branch refs/publish/master:
  remote: If you are using git-review, update to at least git-review 1.27. Otherwise:
  remote: use a SHA1 visible to you, or get update permission on the ref
  remote: User: <redacted>
  remote: Contact an administrator to fix the permissions

To see how popular old git-review versions still are with users,
consider Wikimedia's Gerrit upgrade. They had a few bugs reports about
this issue, a few more pastebins, where users complained, and at least
a dozen of cases where people complained in IRC. All within first five
days after migration.

Co-Author: Kunal Mehta <legoktm@member.fsf.org>
Change-Id: Ia121a90f229e4044b2514132346719fcb8096e9c
This commit is contained in:
Christian Aistleitner
2020-07-02 17:06:19 +02:00
parent f72f9564e7
commit e72efb1338

View File

@@ -1005,7 +1005,15 @@ class ReceiveCommits {
private String buildError(String error, List<String> branches) {
StringBuilder sb = new StringBuilder();
if (branches.size() == 1) {
sb.append("branch ").append(branches.get(0)).append(":\n");
String branch = branches.get(0);
sb.append("branch ").append(branch).append(":\n");
// As of 2020, there are still many git-review <1.27 installations in the wild.
// These users will see failures as their old git-review assumes that
// `refs/publish/...` is still magic, which it isn't. As Gerrit's default error messages are
// misleading for these users, we hint them at upgrading their git-review.
if (branch.startsWith("refs/publish/")) {
sb.append("If you are using git-review, update to at least git-review 1.27. Otherwise:\n");
}
sb.append(error);
return sb.toString();
}