ReceiveCommits: Fix setting [PRIVATE] and [WIP] for updated changes
When the private and/or work-in-progress state of a change is modified by pushing for review using any of the %private, %remove-private, %wip or %ready options, the change notes of the updated changes do not have the new status. To work around this, the new private/WIP state is set by checking for the relevant flags in the magic branch. When none of the private/WIP options are given, i.e. the states are not being set on push, the states are detected from the change notes of the updated changes, which contain the current (correct, unchanged) states. In the latter situation, the states are set from the notes of the first updated change, but then reused for all subsequent updated changes. As a result, if the first updated change is private, all subsequent changes will also be reported with the [PRIVATE] suffix even when they are not actually private. The same occurs for the [WIP] suffix. Fix this by reevaluating the private and wip states for each updated change. Bug: Issue 9024 Change-Id: Ia9cec72cbc5d8820cd788f50239d19df6ee6f1dd
This commit is contained in:
@@ -629,44 +629,39 @@ class ReceiveCommits {
|
||||
addMessage("");
|
||||
addMessage("Updated Changes:");
|
||||
boolean edit = magicBranch != null && (magicBranch.edit || magicBranch.draft);
|
||||
Boolean isPrivate = null;
|
||||
Boolean wip = null;
|
||||
if (magicBranch != null) {
|
||||
if (magicBranch.isPrivate) {
|
||||
isPrivate = true;
|
||||
} else if (magicBranch.removePrivate) {
|
||||
isPrivate = false;
|
||||
}
|
||||
if (magicBranch.workInProgress) {
|
||||
wip = true;
|
||||
} else if (magicBranch.ready) {
|
||||
wip = false;
|
||||
}
|
||||
}
|
||||
for (ReplaceRequest u : updated) {
|
||||
String subject;
|
||||
Change change = u.notes.getChange();
|
||||
if (edit) {
|
||||
try {
|
||||
subject = rp.getRevWalk().parseCommit(u.newCommitId).getShortMessage();
|
||||
} catch (IOException e) {
|
||||
// Log and fall back to original change subject
|
||||
logWarn("failed to get subject for edit patch set", e);
|
||||
subject = u.notes.getChange().getSubject();
|
||||
subject = change.getSubject();
|
||||
}
|
||||
} else {
|
||||
subject = u.info.getSubject();
|
||||
}
|
||||
|
||||
if (isPrivate == null) {
|
||||
isPrivate = u.notes.getChange().isPrivate();
|
||||
}
|
||||
if (wip == null) {
|
||||
wip = u.notes.getChange().isWorkInProgress();
|
||||
boolean isPrivate = change.isPrivate();
|
||||
boolean wip = change.isWorkInProgress();
|
||||
if (magicBranch != null) {
|
||||
if (magicBranch.isPrivate) {
|
||||
isPrivate = true;
|
||||
} else if (magicBranch.removePrivate) {
|
||||
isPrivate = false;
|
||||
}
|
||||
if (magicBranch.workInProgress) {
|
||||
wip = true;
|
||||
} else if (magicBranch.ready) {
|
||||
wip = false;
|
||||
}
|
||||
}
|
||||
|
||||
ChangeReportFormatter.Input input =
|
||||
ChangeReportFormatter.Input.builder()
|
||||
.setChange(u.notes.getChange())
|
||||
.setChange(change)
|
||||
.setSubject(subject)
|
||||
.setIsEdit(edit)
|
||||
.setIsPrivate(isPrivate)
|
||||
|
||||
Reference in New Issue
Block a user