private FileSystem newFileSystem(URI uri) { return ioService.newFileSystem(uri, new HashMap<String, Object>(repo.getEnvironment()) {{ if (!repo.getEnvironment().containsKey("origin")) { put("init", true); } }}); }
private FileSystem newFileSystem(URI uri) { return ioService.newFileSystem(uri, new HashMap<String, Object>(repo.getEnvironment()) {{ if (!repo.getEnvironment().containsKey("origin")) { put("init", true); } put(FileSystemHooks.ExternalUpdate.name(), externalUpdatedCallBack()); put(FileSystemHooks.PostCommit.name(), postCommitCallback()); }}); }
private FileSystem createFileSystem(final GitRepository repo) { FileSystem fs = null; URI uri = null; try { uri = URI.create(repo.getUri()); fs = newFileSystem(uri); } catch (final FileSystemAlreadyExistsException e) { fs = ioService.getFileSystem(uri); Object replaceIfExists = repo.getEnvironment().get("replaceIfExists"); if (replaceIfExists != null && Boolean.valueOf(replaceIfExists.toString())) { org.uberfire.java.nio.file.Path root = fs.getPath(null); ioService.delete(root); fs = newFileSystem(uri); } } catch (final Throwable ex) { throw new RuntimeException(ex.getCause().getMessage(), ex); } return fs; }
private FileSystem createFileSystem(final GitRepository repo) { FileSystem fs; URI uri = null; try { uri = URI.create(repo.getUri()); fs = newFileSystem(uri); } catch (final FileSystemAlreadyExistsException e) { fs = ioService.getFileSystem(uri); Object replaceIfExists = repo.getEnvironment().get("replaceIfExists"); if (replaceIfExists != null && Boolean.valueOf(replaceIfExists.toString())) { org.uberfire.java.nio.file.Path root = fs.getPath(null); ioService.delete(root); fs = newFileSystem(uri); } } catch (final Throwable ex) { throw new RuntimeException(ex); } return fs; }
final Object command = repo.getEnvironment().get( "org.kie.config.cli.command.CliCommand" ); if ( command != null ) { repo.getEnvironment().put( "init", true ); } else { repo.getEnvironment().put( "origin", url ); repo.getEnvironment().put( "username", context.getUser() ); repo.getEnvironment().put( "password", context.getPassword() ); try { uri = URI.create( repo.getUri() ); fs = ioService.newFileSystem( uri, new HashMap<String, Object>( repo.getEnvironment() ) ); } catch ( final FileSystemAlreadyExistsException e ) { fs = ioService.getFileSystem( uri );
@Test public void resolveGitRepositoryClonedBefore() { ExampleRepository playgroundRepository = new ExampleRepository("file:///home/user/folder/.kie-wb-playground"); service.setPlaygroundRepository(playgroundRepository); GitRepository repository = mock(GitRepository.class); Map<String, Object> repositoryEnvironment = new HashMap<>(); repositoryEnvironment.put("origin", playgroundRepository.getUrl()); when(repository.getEnvironment()).thenReturn(repositoryEnvironment); service.getClonedRepositories().add(repository); Repository result = service.resolveGitRepository(playgroundRepository); assertEquals(repository, result); verify(repositoryFactory, never()).newRepository(any(ConfigGroup.class)); } }