@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); } };
File dir = FileKey.resolve(new File(base, name), FS.DETECTED); if (dir == null) continue;
@Override public Transport open(URIish uri, Repository local, String remoteName) throws NoRemoteRepositoryException { File localPath = local.isBare() ? local.getDirectory() : local.getWorkTree(); File path = local.getFS().resolve(localPath, uri.getPath()); // 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(local, uri, path); File gitDir = RepositoryCache.FileKey.resolve(path, local.getFS()); if (gitDir == null) throw new NoRemoteRepositoryException(uri, JGitText.get().notFound); return new TransportLocal(local, uri, gitDir); }
if (RepositoryCache.FileKey.resolve(local, FS.DETECTED) != null) { log.info("Reuse existing local repository " + local); try (Repository repository = Git.open(local).getRepository()) {
File dir = FileKey.resolve(new File(base, name), FS.DETECTED); if (dir == null) continue;
File dir = FileKey.resolve(new File(base, name), FS.DETECTED); if (dir == null) continue;
final File gitDir = RepositoryCache.FileKey.resolve( repoFolder, DETECTED ); final Repository repository; final Git git;
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; } }
File gitDir = RepositoryCache.FileKey.resolve(path, local.getFS());
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; } }
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); } }
/** * Obtain a pointer to a location on disk. * <p> * The method performs some basic guessing to locate the repository. * Searched paths are: * <ol> * <li>{@code directory} // assume exact match</li> * <li>{@code directory} + "/.git" // assume working directory</li> * <li>{@code directory} + ".git" // assume bare</li> * </ol> * * @param directory * location where the repository database might be. * @param fs * the file system abstraction which will be necessary to * perform certain file system operations. * @return a key for the given directory. * @see #exact(File, FS) */ public static FileKey lenient(File directory, FS fs) { final File gitdir = resolve(directory, fs); return new FileKey(gitdir != null ? gitdir : directory, fs); }
/** * Obtain a pointer to a location on disk. * <p> * The method performs some basic guessing to locate the repository. * Searched paths are: * <ol> * <li>{@code directory} // assume exact match</li> * <li>{@code directory} + "/.git" // assume working directory</li> * <li>{@code directory} + ".git" // assume bare</li> * </ol> * * @param directory * location where the repository database might be. * @param fs * the file system abstraction which will be necessary to * perform certain file system operations. * @return a key for the given directory. * @see #exact(File, FS) */ public static FileKey lenient(final File directory, FS fs) { final File gitdir = resolve(directory, fs); return new FileKey(gitdir != null ? gitdir : directory, fs); }
@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); } };
public GitAPI(String gitExe, FilePath workspace, TaskListener listener, EnvVars environment) { this.workspace = workspace; this.listener = listener; this.gitExe = gitExe; this.environment = environment; launcher = new LocalLauncher(GitSCM.VERBOSE ? listener : TaskListener.NULL); if (hasGitRepo()) {//Wrap file repository if exists in order to perform operations and initialize jGitDelegate try { File gitDir = RepositoryCache.FileKey.resolve(new File(workspace.getRemote()), FS.DETECTED); setDelegate(Git.wrap(new FileRepositoryBuilder().setGitDir(gitDir).build())); } catch (IOException e) { e.printStackTrace(listener.getLogger()); } } }
@Override public Transport open(URIish uri, Repository local, String remoteName) throws NoRemoteRepositoryException { File localPath = local.isBare() ? local.getDirectory() : local.getWorkTree(); File path = local.getFS().resolve(localPath, uri.getPath()); // 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(local, uri, path); File gitDir = RepositoryCache.FileKey.resolve(path, local.getFS()); if (gitDir == null) throw new NoRemoteRepositoryException(uri, JGitText.get().notFound); return new TransportLocal(local, uri, gitDir); }
@Override public Transport open(URIish uri, Repository local, String remoteName) throws NoRemoteRepositoryException { File localPath = local.isBare() ? local.getDirectory() : local.getWorkTree(); File path = local.getFS().resolve(localPath, uri.getPath()); // 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(local, uri, path); File gitDir = RepositoryCache.FileKey.resolve(path, local.getFS()); if (gitDir == null) throw new NoRemoteRepositoryException(uri, JGitText.get().notFound); return new TransportLocal(local, uri, gitDir); }
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); } };
private static File _getGitDir(File dir) { do { File gitDir = RepositoryCache.FileKey.resolve(dir, FS.DETECTED); if (gitDir != null) { return gitDir; } dir = dir.getParentFile(); } while (dir != null); throw new GradleException("Unable to locate .git directory"); }
/** * Obtain a pointer to a location on disk. * <p> * The method performs some basic guessing to locate the repository. * Searched paths are: * <ol> * <li>{@code directory} // assume exact match</li> * <li>{@code directory} + "/.git" // assume working directory</li> * <li>{@code directory} + ".git" // assume bare</li> * </ol> * * @param directory * location where the repository database might be. * @param fs * the file system abstraction which will be necessary to * perform certain file system operations. * @return a key for the given directory. * @see #exact(File, FS) */ public static FileKey lenient(File directory, FS fs) { final File gitdir = resolve(directory, fs); return new FileKey(gitdir != null ? gitdir : directory, fs); }