@Override public boolean repoExists(URI repoURI) { File directory = toFile(repoURI); Optional<URI> lookup = ResolveGeogigURI.lookup(directory); return lookup.isPresent(); }
@Override public boolean repoExists(URI repoURI) { File directory = toFile(repoURI); Optional<URI> lookup = ResolveGeogigURI.lookup(directory); return lookup.isPresent(); }
repoLocation = ResolveGeogigURI.lookup(pwd);
repoLocation = ResolveGeogigURI.lookup(pwd);
@Test public void testReinitializeExistingRepoFromInsideASubdirectory() throws Exception { testCreateNewRepo(); File subDir = new File(new File(workingDir, "subdir1"), "subdir2"); assertTrue(subDir.mkdirs()); when(platform.pwd()).thenReturn(subDir); assertTrue(ResolveGeogigURI.lookup(platform.pwd()).isPresent()); assertNotNull(init.call()); verify(platform, atLeastOnce()).pwd(); } }
@Test public void testReinitializeExistingRepoFromInsideASubdirectory() throws Exception { testCreateNewRepo(); File subDir = new File(new File(workingDir, "subdir1"), "subdir2"); assertTrue(subDir.mkdirs()); when(platform.pwd()).thenReturn(subDir); assertTrue(ResolveGeogigURI.lookup(platform.pwd()).isPresent()); assertNotNull(init.call()); verify(platform, atLeastOnce()).pwd(); } }
@Test public void testReinitializeExistingRepo() throws Exception { when(injector.repository()).thenReturn(mockRepo); Optional<Ref> absent = Optional.absent(); when(mockRefParse.call()).thenReturn(absent); Repository created = init.call(); assertSame(mockRepo, created); verify(mockUpdateRef, times(3)).call(); verify(mockUpdateSymRef, times(1)).call(); assertTrue(new File(workingDir, ".geogig").exists()); assertTrue(new File(workingDir, ".geogig").isDirectory()); Ref master = new Ref(Ref.MASTER, RevObjectTestSupport.hashString("hash me")); when(mockRefParse.call()).thenReturn(Optional.of(master)); Context injector = mock(Context.class); when(injector.command(eq(RefParse.class))).thenReturn(mockRefParse); when(injector.platform()).thenReturn(platform); when(injector.repository()).thenReturn(mockRepo); init.setContext(injector); assertTrue(ResolveGeogigURI.lookup(platform.pwd()).isPresent()); assertNotNull(init.call()); verify(platform, atLeastOnce()).pwd(); assertTrue(ResolveGeogigURI.lookup(platform.pwd()).isPresent()); verify(injector, never()).command(eq(UpdateRef.class)); verify(injector, never()).command(eq(UpdateSymRef.class)); assertEquals(RevTree.EMPTY, objectDatabase.get(RevTree.EMPTY_TREE_ID)); }
@Test public void testReinitializeExistingRepo() throws Exception { when(injector.repository()).thenReturn(mockRepo); Optional<Ref> absent = Optional.absent(); when(mockRefParse.call()).thenReturn(absent); Repository created = init.call(); assertSame(mockRepo, created); verify(mockUpdateRef, times(3)).call(); verify(mockUpdateSymRef, times(1)).call(); assertTrue(new File(workingDir, ".geogig").exists()); assertTrue(new File(workingDir, ".geogig").isDirectory()); Ref master = new Ref(Ref.MASTER, RevObjectTestSupport.hashString("hash me")); when(mockRefParse.call()).thenReturn(Optional.of(master)); Context injector = mock(Context.class); when(injector.command(eq(RefParse.class))).thenReturn(mockRefParse); when(injector.platform()).thenReturn(platform); when(injector.repository()).thenReturn(mockRepo); init.setContext(injector); assertTrue(ResolveGeogigURI.lookup(platform.pwd()).isPresent()); assertNotNull(init.call()); verify(platform, atLeastOnce()).pwd(); assertTrue(ResolveGeogigURI.lookup(platform.pwd()).isPresent()); verify(injector, never()).command(eq(UpdateRef.class)); verify(injector, never()).command(eq(UpdateSymRef.class)); assertEquals(RevTree.EMPTY, objectDatabase.get(RevTree.EMPTY_TREE_ID)); }
URI resolvedURI = cloneURI; if ("file".equals(cloneURI.getScheme())) { resolvedURI = ResolveGeogigURI.lookup(new File(cloneURI)).or(cloneURI);
URI resolvedURI = cloneURI; if ("file".equals(cloneURI.getScheme())) { resolvedURI = ResolveGeogigURI.lookup(new File(cloneURI)).or(cloneURI);
URI resolvedURI = cloneURI; if ("file".equals(cloneURI.getScheme())) { resolvedURI = ResolveGeogigURI.lookup(new File(cloneURI)).or(cloneURI);