Search in sources :

Example 21 with Author

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");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Author(com.google.copybara.authoring.Author) Test(org.junit.Test)

Example 22 with Author

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=");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Author(com.google.copybara.authoring.Author) Test(org.junit.Test)

Example 23 with 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>");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Author(com.google.copybara.authoring.Author) Test(org.junit.Test)

Example 24 with Author

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>");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Author(com.google.copybara.authoring.Author) Test(org.junit.Test)

Example 25 with Author

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"));
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Author(com.google.copybara.authoring.Author) Test(org.junit.Test)

Aggregations

Author (com.google.copybara.authoring.Author)47 Test (org.junit.Test)36 DummyRevision (com.google.copybara.testing.DummyRevision)12 ProcessedChange (com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange)12 Change (com.google.copybara.Change)10 Changes (com.google.copybara.Changes)9 Authoring (com.google.copybara.authoring.Authoring)8 DestinationEffect (com.google.copybara.DestinationEffect)7 WriterContext (com.google.copybara.WriterContext)6 ZonedDateTime (java.time.ZonedDateTime)6 TransformResult (com.google.copybara.TransformResult)5 TransformWork (com.google.copybara.TransformWork)5 GitLogEntry (com.google.copybara.git.GitRepository.GitLogEntry)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ImmutableList (com.google.common.collect.ImmutableList)3 Transformation (com.google.copybara.Transformation)3 InvalidAuthorException (com.google.copybara.authoring.InvalidAuthorException)3 ValidationException (com.google.copybara.exception.ValidationException)3 DummyChecker (com.google.copybara.testing.DummyChecker)3 ImmutableMap (com.google.common.collect.ImmutableMap)2