Do not expect ApprovalType of Category SUBM
Pushing a new, rebased Patch Set for a Change failed with a NullPointer if the first Patch Set could not be merged due to a patch conflict. The reason was that there is no ApprovalType of Category SUBM anymore, but it is still stored in the database. Change-Id: I058ba99b835813245283c04fdb08199c94957645 Signed-off-by: Stefan Lay <stefan.lay@sap.com>
This commit is contained in:
committed by
Shawn O. Pearce
parent
6a765190df
commit
71bebadf9f
@@ -187,11 +187,13 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
|||||||
for (final PatchSetApproval ca : db.patchSetApprovals()
|
for (final PatchSetApproval ca : db.patchSetApprovals()
|
||||||
.byPatchSetUser(ps_id, aid)) {
|
.byPatchSetUser(ps_id, aid)) {
|
||||||
final ApprovalCategory.Id category = ca.getCategoryId();
|
final ApprovalCategory.Id category = ca.getCategoryId();
|
||||||
|
if (ApprovalCategory.SUBMIT.equals(category)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (change.getStatus().isOpen()) {
|
if (change.getStatus().isOpen()) {
|
||||||
fs.normalize(approvalTypes.byId(category), ca);
|
fs.normalize(approvalTypes.byId(category), ca);
|
||||||
}
|
}
|
||||||
if (ca.getValue() == 0
|
if (ca.getValue() == 0) {
|
||||||
|| ApprovalCategory.SUBMIT.equals(category)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
psas.put(category, ca);
|
psas.put(category, ca);
|
||||||
@@ -231,11 +233,13 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
|||||||
|
|
||||||
for (PatchSetApproval ca : db.patchSetApprovals().byPatchSet(ps_id)) {
|
for (PatchSetApproval ca : db.patchSetApprovals().byPatchSet(ps_id)) {
|
||||||
final ApprovalCategory.Id category = ca.getCategoryId();
|
final ApprovalCategory.Id category = ca.getCategoryId();
|
||||||
|
if (ApprovalCategory.SUBMIT.equals(category)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (change.getStatus().isOpen()) {
|
if (change.getStatus().isOpen()) {
|
||||||
fs.normalize(approvalTypes.byId(category), ca);
|
fs.normalize(approvalTypes.byId(category), ca);
|
||||||
}
|
}
|
||||||
if (ca.getValue() == 0
|
if (ca.getValue() == 0) {
|
||||||
|| ApprovalCategory.SUBMIT.equals(category)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean keep = true;
|
boolean keep = true;
|
||||||
|
|||||||
@@ -433,8 +433,10 @@ public class ChangeHookRunner {
|
|||||||
Entry<ApprovalCategory.Id, ApprovalCategoryValue.Id> approval) {
|
Entry<ApprovalCategory.Id, ApprovalCategoryValue.Id> approval) {
|
||||||
ApprovalAttribute a = new ApprovalAttribute();
|
ApprovalAttribute a = new ApprovalAttribute();
|
||||||
a.type = approval.getKey().get();
|
a.type = approval.getKey().get();
|
||||||
final ApprovalType at = approvalTypes.byId(approval.getKey());
|
ApprovalType at = approvalTypes.byId(approval.getKey());
|
||||||
a.description = at.getCategory().getName();
|
if (at != null) {
|
||||||
|
a.description = at.getCategory().getName();
|
||||||
|
}
|
||||||
a.value = Short.toString(approval.getValue().get());
|
a.value = Short.toString(approval.getValue().get());
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.git;
|
package com.google.gerrit.server.git;
|
||||||
|
|
||||||
|
import com.google.gerrit.common.data.ApprovalType;
|
||||||
import com.google.gerrit.common.data.ApprovalTypes;
|
import com.google.gerrit.common.data.ApprovalTypes;
|
||||||
import com.google.gerrit.reviewdb.ApprovalCategory;
|
import com.google.gerrit.reviewdb.ApprovalCategory;
|
||||||
import com.google.gerrit.reviewdb.PatchSetApproval;
|
import com.google.gerrit.reviewdb.PatchSetApproval;
|
||||||
@@ -212,10 +213,10 @@ public class CreateCodeReviewNotes {
|
|||||||
if (ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
|
if (ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
|
||||||
submit = a;
|
submit = a;
|
||||||
} else {
|
} else {
|
||||||
ApprovalCategory type = approvalTypes.byId(a.getCategoryId()).getCategory();
|
ApprovalType type = approvalTypes.byId(a.getCategoryId());
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
formatter.appendApproval(
|
formatter.appendApproval(
|
||||||
type,
|
type.getCategory(),
|
||||||
a.getValue(),
|
a.getValue(),
|
||||||
accountCache.get(a.getAccountId()).getAccount());
|
accountCache.get(a.getAccountId()).getAccount());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1358,15 +1358,18 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
|
|||||||
oldCC.add(a.getAccountId());
|
oldCC.add(a.getAccountId());
|
||||||
}
|
}
|
||||||
|
|
||||||
final ApprovalType type =
|
// ApprovalCategory.SUBMIT is still in db but not relevant in git-store
|
||||||
|
if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
|
||||||
|
final ApprovalType type =
|
||||||
approvalTypes.byId(a.getCategoryId());
|
approvalTypes.byId(a.getCategoryId());
|
||||||
if (a.getPatchSetId().equals(priorPatchSet)
|
if (a.getPatchSetId().equals(priorPatchSet)
|
||||||
&& type.getCategory().isCopyMinScore() && type.isMaxNegative(a)) {
|
&& type.getCategory().isCopyMinScore() && type.isMaxNegative(a)) {
|
||||||
// If there was a negative vote on the prior patch set, carry it
|
// If there was a negative vote on the prior patch set, carry it
|
||||||
// into this patch set.
|
// into this patch set.
|
||||||
//
|
//
|
||||||
db.patchSetApprovals().insert(
|
db.patchSetApprovals().insert(
|
||||||
Collections.singleton(new PatchSetApproval(ps.getId(), a)));
|
Collections.singleton(new PatchSetApproval(ps.getId(), a)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!haveAuthor && authorId != null && a.getAccountId().equals(authorId)) {
|
if (!haveAuthor && authorId != null && a.getAccountId().equals(authorId)) {
|
||||||
|
|||||||
@@ -171,7 +171,9 @@ public class PublishComments implements Callable<VoidResult> {
|
|||||||
final short o = a.getValue();
|
final short o = a.getValue();
|
||||||
a.setValue(want.get());
|
a.setValue(want.get());
|
||||||
a.cache(change);
|
a.cache(change);
|
||||||
functionState.normalize(types.byId(a.getCategoryId()), a);
|
if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
|
||||||
|
functionState.normalize(types.byId(a.getCategoryId()), a);
|
||||||
|
}
|
||||||
if (o != a.getValue()) {
|
if (o != a.getValue()) {
|
||||||
// Value changed, ensure we update the database.
|
// Value changed, ensure we update the database.
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user