ReceiveCommits: Remove redundant null checks of magic branch

Change-Id: I53532a27c700416e4fe50ce5c7b910347a11aa15
This commit is contained in:
David Pursehouse
2016-02-12 11:10:57 +09:00
parent bd19d9a380
commit e68af5dfe9

View File

@@ -1782,10 +1782,9 @@ public class ReceiveCommits {
final List<FooterLine> footerLines = commit.getFooterLines(); final List<FooterLine> footerLines = commit.getFooterLines();
final MailRecipients recipients = new MailRecipients(); final MailRecipients recipients = new MailRecipients();
Map<String, Short> approvals = new HashMap<>(); Map<String, Short> approvals = new HashMap<>();
if (magicBranch != null) { checkNotNull(magicBranch);
recipients.add(magicBranch.getMailRecipients()); recipients.add(magicBranch.getMailRecipients());
approvals = magicBranch.labels; approvals = magicBranch.labels;
}
recipients.add(getRecipientsFromFooters( recipients.add(getRecipientsFromFooters(
accountResolver, magicBranch.draft, footerLines)); accountResolver, magicBranch.draft, footerLines));
recipients.remove(me); recipients.remove(me);
@@ -1802,28 +1801,26 @@ public class ReceiveCommits {
.setRequestScopePropagator(requestScopePropagator) .setRequestScopePropagator(requestScopePropagator)
.setSendMail(true) .setSendMail(true)
.setUpdateRef(true)); .setUpdateRef(true));
if (magicBranch != null) { bu.addOp(
changeId,
hashtagsFactory.create(new HashtagsInput(magicBranch.hashtags))
.setRunHooks(false));
if (!Strings.isNullOrEmpty(magicBranch.topic)) {
bu.addOp( bu.addOp(
changeId, changeId,
hashtagsFactory.create(new HashtagsInput(magicBranch.hashtags)) new BatchUpdate.Op() {
.setRunHooks(false)); @Override
if (!Strings.isNullOrEmpty(magicBranch.topic)) { public boolean updateChange(ChangeContext ctx) {
bu.addOp( ctx.getUpdate(psId).setTopic(magicBranch.topic);
changeId, return true;
new BatchUpdate.Op() { }
@Override });
public boolean updateChange(ChangeContext ctx) {
ctx.getUpdate(psId).setTopic(magicBranch.topic);
return true;
}
});
}
} }
bu.execute(); bu.execute();
} }
change = ins.getChange(); change = ins.getChange();
if (magicBranch != null && magicBranch.submit) { if (magicBranch.submit) {
submit(projectControl.controlFor(state.db, change), ins.getPatchSet()); submit(projectControl.controlFor(state.db, change), ins.getPatchSet());
} }
} }