use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class MetadataModuleTest method testRestoreAuthorOtherLabel.
@Test
public void testRestoreAuthorOtherLabel() throws Exception {
Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.restore_author('OTHER_LABEL')");
origin.setAuthor(new Author("remove me", "remove@me.com")).addSimpleChange(0, "A change\n\n" + "OTHER_LABEL=restore me <restore@me.com>\n" + "ORIGINAL_AUTHOR=no no <no@no.com>\n");
wf.run(workdir, ImmutableList.of());
ProcessedChange change = Iterables.getLast(destination.processed);
assertThat(change.getChangesSummary()).doesNotContain("restore@me.com");
assertThat(change.getChangesSummary()).contains("ORIGINAL_AUTHOR=no no <no@no.com>");
assertThat(change.getChangesSummary()).doesNotContain("OTHER_LABEL");
assertThat(change.getAuthor().toString()).isEqualTo("restore me <restore@me.com>");
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class MetadataModuleTest method testMessageTransformerForSquashExtended.
@Test
public void testMessageTransformerForSquashExtended() throws Exception {
runWorkflow(WorkflowMode.SQUASH, "" + "metadata.squash_notes(" + " prefix = 'Importing foo project:\\n'," + " compact = False\n" + ")");
ProcessedChange change = Iterables.getOnlyElement(destination.processed);
assertThat(change.getChangesSummary()).isEqualTo("" + "Importing foo project:\n" + "--\n" + "2 by Foo Baz <foo@baz.com>:\n" + "\n" + "third commit\n" + "\n" + "Extended text\n" + "--\n" + "1 by Foo Bar <foo@bar.com>:\n" + "\n" + "second commit\n" + "\n" + "Extended text\n");
assertThat(change.getAuthor()).isEqualTo(DEFAULT_AUTHOR);
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class MetadataModuleTest method testRestoreAuthorSquash.
@Test
public void testRestoreAuthorSquash() throws Exception {
origin.setAuthor(new Author("remove me", "remove@me.com")).addSimpleChange(0, "A change\n\nORIGINAL_AUTHOR=restore me <restore@me.com>\n").addSimpleChange(1, "Another change\n\n");
createWorkflow(WorkflowMode.SQUASH, "metadata.restore_author()").run(workdir, ImmutableList.of());
ProcessedChange change = Iterables.getLast(destination.processed);
assertThat(change.getAuthor().toString()).isEqualTo("Copybara <no-reply@google.com>");
destination.processed.clear();
createWorkflow(WorkflowMode.SQUASH, "metadata.restore_author(search_all_changes = True)").run(workdir, ImmutableList.of());
change = Iterables.getLast(destination.processed);
assertThat(change.getAuthor().toString()).isEqualTo("restore me <restore@me.com>");
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class MetadataModuleTest method testUseLastChange_map_author.
@Test
public void testUseLastChange_map_author() throws Exception {
runWorkflow(WorkflowMode.SQUASH, "" + "metadata.map_author({" + " 'Foo Baz': 'Public Foo Baz <public@foobaz.com>'," + "}," + " map_all_changes = True)," + "metadata.use_last_change()");
ProcessedChange change = Iterables.getOnlyElement(destination.processed);
assertThat(change.getChangesSummary()).isEqualTo("" + "third commit\n" + "\n" + "Extended text");
assertThat(change.getAuthor()).isEqualTo(new Author("Public Foo Baz", "public@foobaz.com"));
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class MetadataModuleTest method testSquashNotesWithTemplatePrefix.
@Test
public void testSquashNotesWithTemplatePrefix() throws Exception {
runWorkflow(WorkflowMode.SQUASH, "" + "metadata.map_author({" + " 'Foo Bar': 'Public Foo Bar <public@foobar.com>'," + " 'Foo Baz': 'Public Foo Baz <public@foobaz.com>'," + "})," + "metadata.squash_notes(" + " prefix = 'Importing foo version ${COPYBARA_CURRENT_REV}:\\n\\n'" + ")");
ProcessedChange change = Iterables.getOnlyElement(destination.processed);
assertThat(change.getChangesSummary()).isEqualTo("" + "Importing foo version 2:\n" + "\n" + " - 2 third commit by Foo Baz <foo@baz.com>\n" + " - 1 second commit by Foo Bar <foo@bar.com>\n" + "");
assertThat(change.getAuthor()).isEqualTo(DEFAULT_AUTHOR);
}
Aggregations