Search in sources :

Example 16 with Author

use of com.google.copybara.authoring.Author in project copybara by google.

the class MetadataModuleTest method testRestoreAuthorOtherLabelAndSeparator.

@Test
public void testRestoreAuthorOtherLabelAndSeparator() throws Exception {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.restore_author('OTHER_LABEL', separator=': ')");
    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 17 with Author

use of com.google.copybara.authoring.Author in project copybara by google.

the class MetadataModuleTest method testMapAuthor_reversible.

@Test
public void testMapAuthor_reversible() throws Exception {
    Transformation m = skylark.eval("m", "m = " + "metadata.map_author({\n" + "    'a <a@example.com>' : 'b <b@example.com>',\n" + "}," + "reversible = True)");
    TransformWork work = TransformWorks.of(workdir, "test", testingConsole);
    work.setAuthor(new Author("a", "a@example.com"));
    m.transform(work);
    assertThat(work.getAuthor().toString()).isEqualTo("b <b@example.com>");
    m.reverse().transform(work);
    assertThat(work.getAuthor().toString()).isEqualTo("a <a@example.com>");
}
Also used : Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Author(com.google.copybara.authoring.Author) Test(org.junit.Test)

Example 18 with Author

use of com.google.copybara.authoring.Author in project copybara by google.

the class MetadataModuleTest method testSaveAuthorOtherLabelAndSeparator.

@Test
public void testSaveAuthorOtherLabelAndSeparator() throws Exception {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.save_author('OTHER_LABEL', 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("OTHER_LABEL: keep me <keep@me.com>");
    assertThat(change.getChangesSummary()).doesNotContain("ORIGINAL_AUTHOR");
    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 19 with Author

use of com.google.copybara.authoring.Author in project copybara by google.

the class MetadataModuleTest method testRestoreAuthorOtherSeparator.

@Test
public void testRestoreAuthorOtherSeparator() throws Exception {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.restore_author(separator=': ')");
    origin.setAuthor(new Author("remove me", "remove@me.com")).addSimpleChange(0, "A change\n\n" + "ORIGINAL_AUTHOR: restore me <restore@me.com>\n");
    wf.run(workdir, ImmutableList.of());
    ProcessedChange change = Iterables.getLast(destination.processed);
    assertThat(change.getChangesSummary()).doesNotContain("restore@me.com");
    assertThat(change.getChangesSummary()).doesNotContain("ORIGINAL_AUTHOR");
    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 20 with Author

use of com.google.copybara.authoring.Author in project copybara by google.

the class MetadataModuleTest method testsSaveAuthorOtherLabel.

@Test
public void testsSaveAuthorOtherLabel() throws Exception {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.save_author('OTHER_LABEL')");
    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("OTHER_LABEL=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)

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