use of com.google.copybara.authoring.Author in project copybara by google.
the class MetadataModuleTest method testsSaveReplaceAuthor.
@Test
public void testsSaveReplaceAuthor() throws Exception {
Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.save_author()");
origin.setAuthor(new Author("keep me", "keep@me.com")).addSimpleChange(0, "A change\n\nORIGINAL_AUTHOR=bye bye <bye@bye.com>");
wf.run(workdir, ImmutableList.of());
ProcessedChange change = Iterables.getLast(destination.processed);
assertThat(change.getChangesSummary()).contains("ORIGINAL_AUTHOR=keep me <keep@me.com>");
assertThat(change.getChangesSummary()).doesNotContain("bye bye");
}
use of com.google.copybara.authoring.Author in project copybara by google.
the class MetadataModuleTest method testSaveAuthorOtherSeparator.
@Test
public void testSaveAuthorOtherSeparator() throws Exception {
Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.save_author(separator=': ')");
origin.setAuthor(new Author("keep me", "keep@me.com")).addSimpleChange(0, "A change");
wf.run(workdir, ImmutableList.of());
ProcessedChange change = Iterables.getLast(destination.processed);
assertThat(change.getChangesSummary()).contains("ORIGINAL_AUTHOR: keep me <keep@me.com>");
assertThat(change.getChangesSummary()).doesNotContain("ORIGINAL_AUTHOR=");
}
use of com.google.copybara.authoring.Author 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.authoring.Author 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.authoring.Author 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"));
}
Aggregations