Merge branch 'stable-2.6' into stable-2.7
* stable-2.6: Fix: RepoCommandLink's text is wrong fix: NoOp score not displayed for open changes Change-Id: Ib7ba9c2030740422cbda5d95964ab6aab1e96cf2
This commit is contained in:
@@ -86,7 +86,7 @@ public abstract class DownloadCommandLink extends Anchor implements ClickHandler
|
|||||||
String projectName;
|
String projectName;
|
||||||
String ref;
|
String ref;
|
||||||
public RepoCommandLink(String project, String ref) {
|
public RepoCommandLink(String project, String ref) {
|
||||||
super(DownloadCommand.REPO_DOWNLOAD, "checkout");
|
super(DownloadCommand.REPO_DOWNLOAD, "repo download");
|
||||||
this.projectName = project;
|
this.projectName = project;
|
||||||
this.ref = ref;
|
this.ref = ref;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,7 +356,13 @@ public class ChangeJson {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (standard) {
|
if (standard) {
|
||||||
setRecommendedAndDisliked(cd, type, e.getValue());
|
for (PatchSetApproval psa : cd.currentApprovals(db)) {
|
||||||
|
if (type.matches(psa)) {
|
||||||
|
short val = psa.getValue();
|
||||||
|
Account.Id accountId = psa.getAccountId();
|
||||||
|
setLabelScores(type, e.getValue(), val, accountId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (detailed) {
|
if (detailed) {
|
||||||
setLabelValues(type, e.getValue());
|
setLabelValues(type, e.getValue());
|
||||||
@@ -400,36 +406,32 @@ public class ChangeJson {
|
|||||||
return labels;
|
return labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRecommendedAndDisliked(ChangeData cd, LabelType type,
|
private void setLabelScores(LabelType type,
|
||||||
LabelInfo label) throws OrmException {
|
LabelInfo label, short score, Account.Id accountId)
|
||||||
|
throws OrmException {
|
||||||
if (label.approved != null || label.rejected != null) {
|
if (label.approved != null || label.rejected != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.getMin() == null || type.getMax() == null) {
|
if (type.getMin() == null || type.getMax() == null) {
|
||||||
// Unknown or misconfigured type can't have intermediate scores.
|
// Can't set score for unknown or misconfigured type.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
short min = type.getMin().getValue();
|
if (score != 0) {
|
||||||
short max = type.getMax().getValue();
|
if (score == type.getMax().getValue()) {
|
||||||
if (-1 <= min && max <= 1) {
|
label.approved = accountLoader.get(accountId);
|
||||||
// Types with a range of -1..+1 can't have intermediate scores.
|
} else if (score == type.getMin().getValue()) {
|
||||||
return;
|
label.rejected = accountLoader.get(accountId);
|
||||||
|
} else if (score > 0) {
|
||||||
|
label.recommended = accountLoader.get(accountId);
|
||||||
|
label.value = score;
|
||||||
|
} else if (score < 0) {
|
||||||
|
label.disliked = accountLoader.get(accountId);
|
||||||
|
label.value = score;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PatchSetApproval psa : cd.currentApprovals(db)) {
|
|
||||||
short val = psa.getValue();
|
|
||||||
if (val != 0 && min < val && val < max && type.matches(psa)) {
|
|
||||||
if (0 < val) {
|
|
||||||
label.recommended = accountLoader.get(psa.getAccountId());
|
|
||||||
label.value = val != 1 ? val : null;
|
|
||||||
} else {
|
|
||||||
label.disliked = accountLoader.get(psa.getAccountId());
|
|
||||||
label.value = val != -1 ? val : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,22 +542,11 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LabelInfo li = labels.get(type.getName());
|
LabelInfo li = labels.get(type.getName());
|
||||||
if (!standard || li.approved != null || li.rejected != null) {
|
if (!standard) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (val == type.getMax().getValue()) {
|
|
||||||
li.approved = accountLoader.get(accountId);
|
setLabelScores(type, li, val, accountId);
|
||||||
} else if (val == type.getMin().getValue()
|
|
||||||
// A merged change can't have been rejected.
|
|
||||||
&& cd.getChange().getStatus() != Status.MERGED) {
|
|
||||||
li.rejected = accountLoader.get(accountId);
|
|
||||||
} else if (val > 0) {
|
|
||||||
li.recommended = accountLoader.get(accountId);
|
|
||||||
li.value = val;
|
|
||||||
} else if (val < 0) {
|
|
||||||
li.disliked = accountLoader.get(accountId);
|
|
||||||
li.value = val;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return labels;
|
return labels;
|
||||||
|
|||||||
Reference in New Issue
Block a user