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;
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;
private AlternateHandle openAlternate(File objdir) throws IOException { final File parent = objdir.getParentFile(); if (FileKey.isGitRepository(parent, fs)) { FileKey key = FileKey.exact(parent, fs); FileRepository db = (FileRepository) RepositoryCache.open(key); return new AlternateRepository(db); } ObjectDirectory db = new ObjectDirectory(config, objdir, null, fs, null); return new AlternateHandle(db); }
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;
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 {
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;
throw new BuildException("Repository path not specified."); if (!RepositoryCache.FileKey.isGitRepository(new File(src, ".git"), FS.DETECTED)) { throw new BuildException("Specified path (" + src
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;
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;
@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(); } } }
public static void findGitDirsRecursive(File repoRoot, Set<File> gitDirs, boolean lookForNestedRepositories) { if (!repoRoot.exists() || !repoRoot.isDirectory()) { return; } File[] children = repoRoot.listFiles(); // simply ignore null if (children == null) return; for (File child : children) { if (!child.isDirectory()) continue; if (FileKey.isGitRepository(child, FS.DETECTED)) { gitDirs.add(child); } else if (FileKey.isGitRepository(new File(child, Constants.DOT_GIT), FS.DETECTED)) { gitDirs.add(new File(child, Constants.DOT_GIT)); } else if (lookForNestedRepositories) { findGitDirsRecursive(child, gitDirs, lookForNestedRepositories); } } } }
@Override public IStatus validateDrop(Object target, int operation, TransferData transferData) { // check that all paths are valid repository paths String[] folders = (String[]) FileTransfer.getInstance().nativeToJava( transferData); if (folders == null) return Status.CANCEL_STATUS; for (String folder : folders) { File repoFile = new File(folder); if (FileKey.isGitRepository(repoFile, FS.DETECTED)) { continue; } // convenience: also allow the direct parent of .git if (!repoFile.getName().equals(Constants.DOT_GIT)) { File dotgitfile = new File(repoFile, Constants.DOT_GIT); if (FileKey.isGitRepository(dotgitfile, FS.DETECTED)) continue; } return Status.CANCEL_STATUS; } return Status.OK_STATUS; }
@Override protected void run() throws Exception { 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(); } } }
/** * Checks if given folder is a git repository * * @param folder * to check * * @return true if it is a git repository, false otherwise. */ public boolean isValidGitRepository(Path folder) { if (Files.exists(folder) && Files.isDirectory(folder)) { // If it has been at least initialized if (RepositoryCache.FileKey.isGitRepository(folder.toFile(), FS.DETECTED)) { // we are assuming that the clone worked at that time, caller should call hasAtLeastOneReference return true; } else { return false; } } else { return false; } }
@Override public IStatus handleDrop(CommonDropAdapter aDropAdapter, DropTargetEvent aDropTargetEvent, Object aTarget) { String[] data = (String[]) aDropTargetEvent.data; for (String folder : data) { File repoFile = new File(folder); if (FileKey.isGitRepository(repoFile, FS.DETECTED)) Activator.getDefault().getRepositoryUtil() .addConfiguredRepository(repoFile); // also a direct parent of a .git dir is allowed else if (!repoFile.getName().equals(Constants.DOT_GIT)) { File dotgitfile = new File(repoFile, Constants.DOT_GIT); if (FileKey.isGitRepository(dotgitfile, FS.DETECTED)) Activator.getDefault().getRepositoryUtil() .addConfiguredRepository(dotgitfile); } } // the returned Status is not consumed anyway return Status.OK_STATUS; }
private AlternateHandle openAlternate(File objdir) throws IOException { final File parent = objdir.getParentFile(); if (FileKey.isGitRepository(parent, fs)) { FileKey key = FileKey.exact(parent, fs); FileRepository db = (FileRepository) RepositoryCache.open(key); return new AlternateRepository(db); } ObjectDirectory db = new ObjectDirectory(config, objdir, null, fs, null); return new AlternateHandle(db); }
@Override public Repository open(boolean mustExist) throws IOException { if (mustExist && !isGitRepository(path, fs)) throw new RepositoryNotFoundException(path); return new FileRepository(path); }
private AlternateHandle openAlternate(File objdir) throws IOException { final File parent = objdir.getParentFile(); if (FileKey.isGitRepository(parent, fs)) { FileKey key = FileKey.exact(parent, fs); FileRepository db = (FileRepository) RepositoryCache.open(key); return new AlternateRepository(db); } ObjectDirectory db = new ObjectDirectory(config, objdir, null, fs, null); return new AlternateHandle(db); }
public Repository open(final boolean mustExist) throws IOException { if (mustExist && !isGitRepository(path, fs)) throw new RepositoryNotFoundException(path); return new FileRepository(path); }
@Override public Repository open(boolean mustExist) throws IOException { if (mustExist && !isGitRepository(path, fs)) throw new RepositoryNotFoundException(path); return new FileRepository(path); }