InlineEdit: Trigger reindexing on git push

When pushing with magic branch %edit option, there was no operation
added and as a consequence no reindexing took place, which lead to
non working has:edit predicate.

To rectify, add dummy change edit mutation operation, that sets pseudo
dirty flag to trigger the reindexing. Update tests correspondingly to
verify that after the git push to refs/for/master%edit the index is
aware of the edit.

Reported-By: Alice Kober-Sotzek <aliceks@google.com>
Bug: Issue 5350
Change-Id: I4f366bcbb9d2aa45c288c636b1ba2c3e485f8fb4
This commit is contained in:
David Ostrovsky
2017-02-22 06:42:11 +01:00
committed by David Pursehouse
parent 646db67977
commit 3cb7c81a68
2 changed files with 13 additions and 0 deletions

View File

@@ -406,6 +406,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
r.assertOkStatus();
Optional<EditInfo> edit = getEdit(r.getChangeId());
assertThat(edit).isAbsent();
assertThat(query("has:edit")).isEmpty();
// specify edit as option
r = amendChange(r.getChangeId(), "refs/for/master%edit");
@@ -420,6 +421,9 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
+ " "
+ editInfo.commit.subject
+ " [EDIT]\n");
// verify that the re-indexing was triggered for the change
assertThat(query("has:edit")).hasSize(1);
}
@Test

View File

@@ -2500,6 +2500,15 @@ public class ReceiveCommits {
cmd.execute(rp);
}
if (magicBranch != null && magicBranch.edit) {
bu.addOp(
notes.getChangeId(),
new BatchUpdate.Op() {
@Override
public boolean updateChange(ChangeContext ctx) throws Exception {
// return pseudo dirty state to trigger reindexing
return true;
}
});
return;
}
RevWalk rw = rp.getRevWalk();