Search in sources :

Example 21 with CannotResolveRevisionException

use of com.google.copybara.exception.CannotResolveRevisionException in project copybara by google.

the class GitOriginTest method testNoChange.

@Test
public void testNoChange() throws Exception {
    // This is needed to initialize the local repo
    origin.resolve(firstCommitRef);
    CannotResolveRevisionException thrown = assertThrows(CannotResolveRevisionException.class, () -> origin.resolve("foo"));
    assertThat(thrown).hasMessageThat().contains("Cannot find reference(s): [foo, refs/tags/*]");
}
Also used : CannotResolveRevisionException(com.google.copybara.exception.CannotResolveRevisionException) Test(org.junit.Test)

Example 22 with CannotResolveRevisionException

use of com.google.copybara.exception.CannotResolveRevisionException in project copybara by google.

the class HgRepositoryTest method testIdentify.

@Test
public void testIdentify() throws Exception {
    addAndCommitFile("foo");
    ImmutableList<HgLogEntry> commits = repository.log().run();
    String globalId = commits.get(0).getGlobalId();
    for (String reference : ImmutableList.of(globalId, "tip", String.valueOf(0), "default")) {
        HgRevision revision = repository.identify(reference);
        assertThat(revision.getGlobalId()).isEqualTo(globalId);
        assertThat(revision.contextReference()).isEqualTo(reference);
    }
    CannotResolveRevisionException expected = assertThrows(CannotResolveRevisionException.class, () -> repository.identify("not_a_branch"));
    assertThat(expected.getMessage()).contains("Unknown revision");
}
Also used : CannotResolveRevisionException(com.google.copybara.exception.CannotResolveRevisionException) HgLogEntry(com.google.copybara.hg.HgRepository.HgLogEntry) Test(org.junit.Test)

Example 23 with CannotResolveRevisionException

use of com.google.copybara.exception.CannotResolveRevisionException in project copybara by google.

the class HgOriginTest method testResolveNullOrEmptyReferenceNoSourceRef.

@Test
public void testResolveNullOrEmptyReferenceNoSourceRef() throws Exception {
    origin = skylark.eval("result", String.format("result = hg.origin(\n" + "    url = '%s', \n" + "    ref = '')", url));
    CannotResolveRevisionException expected1 = assertThrows(CannotResolveRevisionException.class, () -> origin.resolve(null));
    assertThat(expected1.getMessage()).isEqualTo("No source reference was passed through the" + " command line and the default reference is empty");
    CannotResolveRevisionException expected2 = assertThrows(CannotResolveRevisionException.class, () -> origin.resolve(""));
    assertThat(expected2.getMessage()).isEqualTo("No source reference was passed through the" + " command line and the default reference is empty");
}
Also used : CannotResolveRevisionException(com.google.copybara.exception.CannotResolveRevisionException) Test(org.junit.Test)

Aggregations

CannotResolveRevisionException (com.google.copybara.exception.CannotResolveRevisionException)23 Test (org.junit.Test)10 CharMatcher (com.google.common.base.CharMatcher)6 ProfilerTask (com.google.copybara.profiler.Profiler.ProfilerTask)5 ImmutableList (com.google.common.collect.ImmutableList)4 Endpoint (com.google.copybara.Endpoint)4 EmptyChangeException (com.google.copybara.exception.EmptyChangeException)4 RepoException (com.google.copybara.exception.RepoException)4 PullRequest (com.google.copybara.git.github.api.PullRequest)4 Change (com.google.copybara.Change)3 Path (java.nio.file.Path)3 Matcher (java.util.regex.Matcher)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Preconditions (com.google.common.base.Preconditions)2 Splitter (com.google.common.base.Splitter)2 Collections2 (com.google.common.collect.Collections2)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)2 ImmutableListMultimap.toImmutableListMultimap (com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap)2 ImmutableMap (com.google.common.collect.ImmutableMap)2