Provide more informative error message for Change-Id conflicts
Currently, when two or more commits in the same push to refs/for has the same Change-Id, the user is asked to "squash commits first". This is only informative when the user responds to a code review by adding a new commit with the same Change-Id on top of the previous patch set. When there is a series of five commits where two of them have the same Change-Id, squashing the commits might not give the desired result. This change improved the error message to be more intuitive so the user can act accordingly. Change-Id: Iffaa5e3d8c37ac37e9b5f432c888aadf644ec639
This commit is contained in:
@@ -31,7 +31,7 @@ occurring and what can be done to solve it.
|
||||
* link:error-permission-denied.html[Permission denied (publickey)]
|
||||
* link:error-prohibited-by-gerrit.html[prohibited by Gerrit]
|
||||
* link:error-project-not-found.html[Project not found: ...]
|
||||
* link:error-squash-commits-first.html[squash commits first]
|
||||
* link:error-same-change-id-in-multiple-changes.html[same Change-Id in multiple changes]
|
||||
* link:error-upload-denied.html[Upload denied for project \'...']
|
||||
* link:error-not-allowed-to-upload-merges.html[you are not allowed to upload merges]
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
= squash commits first
|
||||
= same Change-Id in multiple changes
|
||||
|
||||
With this error message Gerrit rejects to push a commit if it
|
||||
contains the same Change-Id as a predecessor commit.
|
||||
@@ -50,8 +50,10 @@ than two commits that have the same Change-Id).
|
||||
Writing objects: 100% (6/6), 558 bytes, done.
|
||||
Total 6 (delta 0), reused 0 (delta 0)
|
||||
To ssh://JohnDoe@host:29418/myProject
|
||||
! [remote rejected] HEAD -> refs/for/master (squash commits first)
|
||||
! [remote rejected] HEAD -> refs/for/master (same Change-Id in multiple changes.
|
||||
Squash the commits with the same Change-Id or ensure Change-Ids are unique for each commit)
|
||||
error: failed to push some refs to 'ssh://JohnDoe@host:29418/myProject'
|
||||
|
||||
----
|
||||
|
||||
If it was the intention to rework a change and push a new patch
|
@@ -193,6 +193,11 @@ public class ReceiveCommits {
|
||||
"Please read the documentation and contact an administrator\n"
|
||||
+ "if you feel the configuration is incorrect";
|
||||
|
||||
private static final String SAME_CHANGE_ID_IN_MULTIPLE_CHANGES =
|
||||
"same Change-Id in multiple changes.\n"
|
||||
+ "Squash the commits with the same Change-Id or "
|
||||
+ "ensure Change-Ids are unique for each commit";
|
||||
|
||||
private enum Error {
|
||||
CONFIG_UPDATE("You are not allowed to perform this operation.\n"
|
||||
+ "Configuration changes can only be pushed by project owners\n"
|
||||
@@ -1590,7 +1595,7 @@ public class ReceiveCommits {
|
||||
|
||||
for (ChangeLookup p : pending) {
|
||||
if (newChangeIds.contains(p.changeKey)) {
|
||||
reject(magicBranch.cmd, "squash commits first");
|
||||
reject(magicBranch.cmd, SAME_CHANGE_ID_IN_MULTIPLE_CHANGES);
|
||||
newChanges = Collections.emptyList();
|
||||
return;
|
||||
}
|
||||
@@ -1991,7 +1996,7 @@ public class ReceiveCommits {
|
||||
// very common error due to users making a new commit rather than
|
||||
// amending when trying to address review comments.
|
||||
if (rp.getRevWalk().isMergedInto(prior, newCommit)) {
|
||||
reject(inputCommand, "squash commits first");
|
||||
reject(inputCommand, SAME_CHANGE_ID_IN_MULTIPLE_CHANGES);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user