List of usage examples for org.eclipse.jgit.lib Repository getDirectory
public File getDirectory()
From source file:jetbrains.buildServer.buildTriggers.vcs.git.FetchCommandImpl.java
License:Apache License
private GeneralCommandLine createFetcherCommandLine(@NotNull final Repository repository, @NotNull final URIish uri) { GeneralCommandLine cl = new GeneralCommandLine(); cl.setWorkingDirectory(repository.getDirectory()); cl.setExePath(myConfig.getFetchProcessJavaPath()); cl.addParameters(myConfig.getOptionsForSeparateProcess()); cl.setPassParentEnvs(myConfig.passEnvToChildProcess()); cl.addParameters("-Xmx" + myConfig.getFetchProcessMaxMemory(), "-cp", myConfig.getFetchClasspath(), myConfig.getFetcherClassName(), uri.toString());//last parameter is not used in Fetcher, but is useful to distinguish fetch processes return cl;// w w w. ja v a 2 s . c om }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.FetchCommandImpl.java
License:Apache License
private String getDebugInfo(Repository db, URIish uri, Collection<RefSpec> refSpecs) { StringBuilder sb = new StringBuilder(); for (RefSpec spec : refSpecs) { sb.append(spec).append(" "); }/*from w ww . java 2 s .c o m*/ return " (" + (db.getDirectory() != null ? db.getDirectory().getAbsolutePath() + ", " : "") + uri.toString() + "#" + sb.toString() + ")"; }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.GitMapFullPath.java
License:Apache License
public void invalidateRevisionsCache(@NotNull Repository db, @NotNull Map<String, Ref> oldRefs, @NotNull Map<String, Ref> newRefs) throws IOException { try {/*from www . j a v a 2 s . c o m*/ if (myConfig.ignoreFetchedCommits()) { myCache.resetNegativeEntries(db.getDirectory()); } else { Set<String> newCommits = getNewCommits(db, oldRefs, newRefs); myCache.resetNegativeEntries(db.getDirectory(), newCommits); } } catch (IOException e) { LOG.warn("Error while resetting commits cache for repository " + db.getDirectory(), e); } }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.OperationContext.java
License:Apache License
@NotNull public StoredConfig getConfig(@NotNull Repository r) { String repositoryPath = r.getDirectory().getAbsolutePath(); StoredConfig result = myConfigsCache.get(repositoryPath); if (result == null) { result = r.getConfig();//from ww w . j av a 2s . c om myConfigsCache.put(repositoryPath, result); } return result; }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.submodules.SubmoduleResolverImpl.java
License:Apache License
public Repository resolveRepository(@NotNull String submoduleUrl) throws VcsException, URISyntaxException { LOG.debug("Resolve repository for URL: " + submoduleUrl); final URIish uri = resolveSubmoduleUrl(submoduleUrl); Repository r = myContext.getRepositoryFor(uri); LOG.debug("Repository dir for submodule " + submoduleUrl + " is " + r.getDirectory().getAbsolutePath()); return r;//from www. j a v a2 s . c o m }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.submodules.TeamCitySubmoduleResolver.java
License:Apache License
protected Repository resolveRepository(String path, String submoduleUrl) throws IOException, VcsException, URISyntaxException { LOG.debug("Resolve repository for URL: " + submoduleUrl); final URIish uri = resolveUrl(submoduleUrl); Repository r = myContext.getRepositoryFor(uri); LOG.debug("Repository dir for submodule " + submoduleUrl + " is " + r.getDirectory().getAbsolutePath()); return r;/*from ww w . ja v a 2s . c om*/ }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.tests.RepositoryManagerTest.java
License:Apache License
private void should_use_same_dir_for_same_urls() throws Exception { RepositoryManager repositoryManager = getRepositoryManager(); Repository noAuthRepository = repositoryManager.openRepository(new URIish("ssh://some.org/repository.git")); String path = noAuthRepository.getDirectory().getCanonicalPath(); assertEquals(path, getRepositoryPath(repositoryManager, "ssh://some.org/repository.git")); assertEquals(path, getRepositoryPath(repositoryManager, "ssh://name@some.org/repository.git")); assertEquals(path, getRepositoryPath(repositoryManager, "ssh://name:pass@some.org/repository.git")); assertEquals(path, getRepositoryPath(repositoryManager, "ssh://other-name@some.org/repository.git")); assertEquals(path, getRepositoryPath(repositoryManager, "ssh://other-name:pass@some.org/repository.git")); }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.tests.RepositoryManagerTest.java
License:Apache License
public void get_repository_in_dir_with_existing_config_without_teamcity_remote() throws Exception { File customDir = myTempFiles.createTempDir(); Repository r = new RepositoryBuilder().setGitDir(customDir).setBare().build(); assertNull(r.getConfig().getString("teamcity", null, "remote")); RepositoryManager repositoryManager = getRepositoryManager(); Repository r2 = repositoryManager.openRepository(customDir, new URIish("git://some.org/repo.git")); assertEquals(customDir, r2.getDirectory()); assertEquals("git://some.org/repo.git", r2.getConfig().getString("teamcity", null, "remote")); }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.tests.RepositoryManagerTest.java
License:Apache License
private String getRepositoryPath(@NotNull RepositoryManager repositoryManager, @NotNull final String url) throws Exception { Repository repository = repositoryManager.openRepository(new URIish(url)); return repository.getDirectory().getCanonicalPath(); }
From source file:main.Repositories.java
/** * Get the files from a given repository on github * @param localPath The folder on disk where the files will be placed * @param location The username/repository identification. We'd * expect something like triplecheck/reporter */// w w w. ja va 2s . c o m public void download(final File localPath, final String location) { // we can't have any older files files.deleteDir(localPath); final String REMOTE_URL = "https://github.com/" + location + ".git"; try { Git.cloneRepository().setURI(REMOTE_URL).setDirectory(localPath).call(); // now open the created repository FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repository = builder.setGitDir(localPath).readEnvironment() // scan environment GIT_* variables .findGitDir() // scan up the file system tree .build(); System.out.println("Downloaded repository: " + repository.getDirectory()); repository.close(); } catch (IOException ex) { Logger.getLogger(Repositories.class.getName()).log(Level.SEVERE, null, ex); } catch (GitAPIException ex) { Logger.getLogger(Repositories.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("--> " + location); }