use of com.google.copybara.TransformWork 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>");
}
use of com.google.copybara.TransformWork in project copybara by google.
the class MetadataModuleTest method testSquashNotesWithMerge.
@Test
public void testSquashNotesWithMerge() throws Exception {
Changes changes = new Changes(ImmutableList.of(new Change<>(new DummyRevision("3"), ORIGINAL_AUTHOR, "merge", fakeDate(), ImmutableListMultimap.of(), /*changeFiles=*/
null, /*merge=*/
true, ImmutableList.of(new DummyRevision("10"), new DummyRevision("20"))), new Change<>(new DummyRevision("2"), ORIGINAL_AUTHOR, "change2", fakeDate(), ImmutableListMultimap.of()), new Change<>(new DummyRevision("1"), ORIGINAL_AUTHOR, "change1", fakeDate(), ImmutableListMultimap.of())), ImmutableList.of());
TransformWork work = TransformWorks.of(workdir, "the message", testingConsole).withChanges(changes);
// The default is to use merges, since git.origin does --first-parent by default
skylark.<MetadataSquashNotes>eval("s", "s = metadata.squash_notes()").transform(work);
assertThat(work.getMessage()).isEqualTo("Copybara import of the project:\n" + "\n" + " - 3 merge by Foo Bar <foo@bar.com>\n" + " - 2 change2 by Foo Bar <foo@bar.com>\n" + " - 1 change1 by Foo Bar <foo@bar.com>\n");
work = TransformWorks.of(workdir, "the message", testingConsole).withChanges(changes);
skylark.<MetadataSquashNotes>eval("s", "s = metadata.squash_notes(use_merge = False)").transform(work);
assertThat(work.getMessage()).isEqualTo("Copybara import of the project:\n" + "\n" + " - 2 change2 by Foo Bar <foo@bar.com>\n" + " - 1 change1 by Foo Bar <foo@bar.com>\n");
}
use of com.google.copybara.TransformWork in project copybara by google.
the class MetadataModuleTest method testExposeLabelAll.
@Test
public void testExposeLabelAll() throws Exception {
TransformWork tw = TransformWorks.of(workdir, "some message\n\n" + "LABEL=aaa", testingConsole).withChanges(new Changes(ImmutableList.of(toChange(new DummyRevision("1").withLabels(ImmutableListMultimap.of("LABEL", "bbb")), ORIGINAL_AUTHOR), toChange(new DummyRevision("2").withLabels(ImmutableListMultimap.of("LABEL", "bbb")), ORIGINAL_AUTHOR), toChange(new DummyRevision("2").withLabels(ImmutableListMultimap.of("LABEL", "ccc")), ORIGINAL_AUTHOR)), ImmutableList.of())).withResolvedReference(new DummyRevision("123").withLabels(ImmutableListMultimap.of("LABEL", "ddd")));
Transformation t = skylark.eval("t", "t = " + "metadata.expose_label('LABEL', 'NEW_VALUE', all = True)");
t.transform(tw);
assertThat(tw.getMessage()).isEqualTo("some message\n" + "\n" + "LABEL=aaa\n" + "NEW_VALUE=aaa\n" + "NEW_VALUE=bbb\n" + "NEW_VALUE=ccc\n" + "NEW_VALUE=ddd\n");
}
use of com.google.copybara.TransformWork in project copybara by google.
the class RevisionMigratorTest method testUndefinedReferenceGetsNotUpdated.
@Test
public void testUndefinedReferenceGetsNotUpdated() throws Exception {
String desc = "This is an awesome change, building on http://internalReviews.com/5";
TransformWork work = getTransformWork(desc);
referenceMigrator.transform(work);
assertThat(work.getMessage()).isEqualTo("This is an awesome change, building on http://internalReviews.com/5");
}
use of com.google.copybara.TransformWork in project copybara by google.
the class RevisionMigratorTest method testMultipleGetUpdated.
@Test
public void testMultipleGetUpdated() throws Exception {
String desc = "This is an awesome change, building on http://internalReviews.com/5005, " + "http://internalReviews.com/53, http://internalReviews.com/5, " + "http://internalReviews.com/14 and stuff.";
TransformWork work = getTransformWork(desc);
referenceMigrator.transform(work);
assertThat(work.getMessage()).isEqualTo("This is an awesome change, building on http://internalReviews.com/5005, " + "http://externalreviews.com/view?35, http://internalReviews.com/5, " + "http://externalreviews.com/view?e and stuff.");
}
Aggregations