@Override public Transport open(URIish uri) throws NotSupportedException, TransportException { File path = FS.DETECTED.resolve(new File("."), uri.getPath()); //$NON-NLS-1$ // If the reference is to a local file, C Git behavior says // assume this is a bundle, since repositories are directories. if (path.isFile()) return new TransportBundleFile(uri, path); File gitDir = RepositoryCache.FileKey.resolve(path, FS.DETECTED); if (gitDir == null) throw new NoRemoteRepositoryException(uri, JGitText.get().notFound); return new TransportLocal(uri, gitDir); } };
while (current != null) { File dir = new File(current, DOT_GIT); if (FileKey.isGitRepository(dir, tryFS)) { setGitDir(dir); break; } else if (FileKey.isGitRepository(current, tryFS)) { setGitDir(current); break;
if (RepositoryCache.FileKey.resolve(local, FS.DETECTED) != null) { log.info("Reuse existing local repository " + local); try (Repository repository = Git.open(local).getRepository()) {
if (!RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) { if (!RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) { errorMessage = NLS .bind(UIText.RepositoriesView_ClipboardContentNoGitRepoMessage,
continue; if (FileKey.isGitRepository(child, FS.DETECTED)) { try { strings.add(child.getCanonicalPath()); .bind(UIText.RepositorySearchDialog_RepositoriesFound_message, Integer.valueOf(strings.size()))); } else if (FileKey.isGitRepository(new File(child, Constants.DOT_GIT), FS.DETECTED)) { try {
repository = RepositoryCache.open(FileKey.lenient(gitdir, FS.DETECTED), true);
while (current != null) { File dir = new File(current, DOT_GIT); if (FileKey.isGitRepository(dir, tryFS)) { setGitDir(dir); break; } else if (FileKey.isGitRepository(current, tryFS)) { setGitDir(current); break;
while (current != null) { File dir = new File(current, DOT_GIT); if (FileKey.isGitRepository(dir, tryFS)) { setGitDir(dir); break; } else if (FileKey.isGitRepository(current, tryFS)) { setGitDir(current); break;
final File gitDir = RepositoryCache.FileKey.resolve( repoFolder, DETECTED ); final Repository repository; final Git git;
@Override protected void run() throws Exception { mxBean = ManagementFactory.getThreadMXBean(); if (!mxBean.isCurrentThreadCpuTimeSupported()) throw die("Current thread CPU time not supported on this JRE"); if (gitDirs.isEmpty()) { FileRepositoryBuilder rb = new FileRepositoryBuilder() // .setGitDir(new File(gitdir)) // .readEnvironment() // .findGitDir(); if (rb.getGitDir() == null) throw die(CLIText.get().cantFindGitDirectory); gitDirs.add(rb.getGitDir()); } for (File dir : gitDirs) { FileRepositoryBuilder rb = new FileRepositoryBuilder(); if (RepositoryCache.FileKey.isGitRepository(dir, FS.DETECTED)) rb.setGitDir(dir); else rb.findGitDir(dir); Repository db = rb.build(); try { run(db); } finally { db.close(); } } }
File gitDir = RepositoryCache.FileKey.resolve(path, local.getFS());
throw new BuildException("Repository path not specified."); if (!RepositoryCache.FileKey.isGitRepository(new File(src, ".git"), FS.DETECTED)) { throw new BuildException("Specified path (" + src
public Repository createRepository(String name) throws RepositoryNotFoundException { if (isUnreasonableName(name)) { throw new RepositoryNotFoundException("Invalid name: " + name); } try { File dir = FileKey.resolve(gitDirOf(name), FS.DETECTED); FileKey loc; if (dir != null) { // Already exists on disk, use the repository we found. // loc = FileKey.exact(dir, FS.DETECTED); } else { // It doesn't exist under any of the standard permutations // of the repository name, so prefer the standard bare name. // if (!name.endsWith(Constants.DOT_GIT_EXT)) { name = name + Constants.DOT_GIT_EXT; } loc = FileKey.exact(new File(basePath, name), FS.DETECTED); } return RepositoryCache.open(loc, false); } catch (IOException e1) { final RepositoryNotFoundException e2; e2 = new RepositoryNotFoundException("Cannot open repository " + name); e2.initCause(e1); throw e2; } }
if (isGitRepository(directory, fs)) return directory; if (isGitRepository(new File(directory, Constants.DOT_GIT), fs)) return new File(directory, Constants.DOT_GIT); if (isGitRepository(new File(parent, name + Constants.DOT_GIT_EXT), fs)) return new File(parent, name + Constants.DOT_GIT_EXT); return null;
public Repository createRepository(String name) throws RepositoryNotFoundException { if (isUnreasonableName(name)) { throw new RepositoryNotFoundException("Invalid name: " + name); } try { File dir = FileKey.resolve(gitDirOf(name), FS.DETECTED); FileKey loc; if (dir != null) { // Already exists on disk, use the repository we found. // loc = FileKey.exact(dir, FS.DETECTED); } else { // It doesn't exist under any of the standard permutations // of the repository name, so prefer the standard bare name. // if (!name.endsWith(Constants.DOT_GIT_EXT)) { name = name + Constants.DOT_GIT_EXT; } loc = FileKey.exact(new File(basePath, name), FS.DETECTED); } return RepositoryCache.open(loc, false); } catch (IOException e1) { final RepositoryNotFoundException e2; e2 = new RepositoryNotFoundException("Cannot open repository " + name); e2.initCause(e1); throw e2; } }
if (isGitRepository(directory, fs)) return directory; if (isGitRepository(new File(directory, Constants.DOT_GIT), fs)) return new File(directory, Constants.DOT_GIT); if (isGitRepository(new File(parent, name + Constants.DOT_GIT_EXT), fs)) return new File(parent, name + Constants.DOT_GIT_EXT); return null;
public static Git cloneRepository(final File repoFolder, final String fromURI, final CredentialsProvider credentialsProvider) { if (!repoFolder.getName().endsWith(DOT_GIT_EXT)) { throw new RuntimeException("Invalid name"); } try { final File gitDir = RepositoryCache.FileKey.resolve(repoFolder, DETECTED); final Repository repository; final Git git; if (gitDir != null && gitDir.exists()) { repository = new FileRepository(gitDir); git = new Git(repository); } else { git = Git.cloneRepository() .setBare(true) .setCloneAllBranches(true) .setURI(fromURI) .setDirectory(repoFolder) .setCredentialsProvider(credentialsProvider) .call(); repository = git.getRepository(); } fetchRepository(git, credentialsProvider); repository.close(); return git; } catch (final Exception ex) { throw new RuntimeException(ex); } }