More detailed error message when failing to upload new change
When the uploaded change cannot be created on the underlying
Git repository, a more descriptive error message is displayed
on both client and server side.
This allows to troubleshoot internal errors (e.g. JGit lock failures
or other causes) and help out in the resolution.
Example:
Previous message in case of ref contention:
internal server error
New message:
Unable to create changes: LOCK_FAILED
Issue: 2284
GerritForge-Issue: GERICS-312
Change-Id: I8bfebc350c964484f25d575e96261d4a422b02d0
(cherry picked from commit 64c1b3e206)
This commit is contained in:
@@ -711,16 +711,29 @@ public class ReceiveCommits {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> lastCreateChangeErrors = Lists.newArrayList();
|
||||
for (CreateRequest create : newChanges) {
|
||||
if (create.cmd.getResult() == OK) {
|
||||
okToInsert++;
|
||||
} else {
|
||||
String createChangeResult =
|
||||
String.format("%s %s",
|
||||
create.cmd.getResult(),
|
||||
Strings.nullToEmpty(create.cmd.getMessage())).trim();
|
||||
lastCreateChangeErrors.add(createChangeResult);
|
||||
log.error(String.format("Command %s on %s:%s not completed: %s",
|
||||
create.cmd.getType(),
|
||||
project.getName(),
|
||||
create.cmd.getRefName(),
|
||||
createChangeResult));
|
||||
}
|
||||
}
|
||||
|
||||
if (okToInsert != replaceCount + newChanges.size()) {
|
||||
// One or more new references failed to create. Assume the
|
||||
// system isn't working correctly anymore and abort.
|
||||
reject(magicBranch.cmd, "internal server error");
|
||||
reject(magicBranch.cmd, "Unable to create changes: "
|
||||
+ Joiner.on(' ').join(lastCreateChangeErrors));
|
||||
log.error(String.format(
|
||||
"Only %d of %d new change refs created in %s; aborting",
|
||||
okToInsert, replaceCount + newChanges.size(), project.getName()));
|
||||
|
||||
Reference in New Issue
Block a user