List of usage examples for org.eclipse.jgit.lib Constants DOT_GIT
String DOT_GIT
To view the source code for org.eclipse.jgit.lib Constants DOT_GIT.
Click Source Link
From source file:org.eclipse.orion.server.filesystem.git.GitFileStore.java
License:Open Source License
public boolean isCloned() { return getWorkingDir().exists() && RepositoryCache.FileKey .isGitRepository(new File(getWorkingDir(), Constants.DOT_GIT), FS.DETECTED); }
From source file:org.eclipse.orion.server.filesystem.git.GitFileStore.java
License:Open Source License
private boolean initBare() throws URISyntaxException, IOException { String scheme = getUrl().getProtocol(); String path = getUrl().getPath(); if (scheme != null && !scheme.equals("file")) { throw new IllegalArgumentException("#canInit() has mistaken, this is not a local file system URL"); }//from w w w. j a v a 2 s . co m File sharedRepo = new File(path); // remember, we know how to init only local repositories if (sharedRepo.exists() && RepositoryCache.FileKey.isGitRepository(new File(sharedRepo, Constants.DOT_GIT), FS.DETECTED)) { // nothing to init, a repository already exists at the given location return false; } sharedRepo.mkdir(); LogHelper.log( new Status(IStatus.INFO, Activator.PI_GIT, 1, "Initializing bare repository for " + this, null)); FileRepository repository = new FileRepository(new File(sharedRepo, Constants.DOT_GIT)); repository.create(true); return true; }
From source file:org.eclipse.orion.server.git.BaseToBranchConverter.java
License:Open Source License
private static IPath findClonePath(IPath filePath) throws CoreException { // /file/{projectId}[/{path}] -> /{projectId}[/{path}] IPath p = filePath.removeFirstSegments(1); while (p.segmentCount() > 0) { IFileStore fileStore = NewFileServlet.getFileStore(p); if (fileStore == null) return null; File file = fileStore.toLocalFile(EFS.NONE, null); if (RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED)) { return p; }/*from w ww . j ava 2 s . com*/ p = p.removeLastSegments(1); } return null; }
From source file:org.eclipse.orion.server.git.GitFileDecorator.java
License:Open Source License
/** * If this server is configured to use git by default, then each project creation that is not * already in a repository needs to have a git -init performed to initialize the repository. */// w w w .ja v a 2s. c o m private void initGitRepository(HttpServletRequest request, IPath targetPath, JSONObject representation) { //project creation URL is of the form POST /workspace/<id> if (!(targetPath.segmentCount() == 2 && "workspace".equals(targetPath.segment(0)) //$NON-NLS-1$ && Method.POST.equals(Method.fromString(request.getMethod())))) return; String scm = PreferenceHelper.getString(ServerConstants.CONFIG_FILE_DEFAULT_SCM, "").toLowerCase(); //$NON-NLS-1$ if (!"git".equals(scm)) //$NON-NLS-1$ return; try { IFileStore store = WebProject.fromId(representation.optString(ProtocolConstants.KEY_ID)) .getProjectStore(); //create repository in each project if it doesn't already exist File localFile = store.toLocalFile(EFS.NONE, null); File gitDir = GitUtils.getGitDir(localFile); if (gitDir == null) { gitDir = new File(localFile, Constants.DOT_GIT); FileRepository repo = new FileRepositoryBuilder().setGitDir(gitDir).build(); repo.create(); //we need to perform an initial commit to workaround JGit bug 339610. Git git = new Git(repo); git.add().addFilepattern(".").call(); //$NON-NLS-1$ git.commit().setMessage("Initial commit").call(); } } catch (Exception e) { //just log it - this is not the purpose of the file decorator LogHelper.log(e); } }
From source file:org.eclipse.orion.server.git.objects.Clone.java
License:Open Source License
private FileRepository getRepository() throws IOException { if (db == null) db = new FileRepository(new File(new File(getContentLocation()), Constants.DOT_GIT)); return db;/* w w w . j av a 2 s . c om*/ }
From source file:org.eclipse.orion.server.git.servlets.GitUtils.java
License:Open Source License
public static File getGitDir(File file) { if (file.exists()) { while (file != null) { if (RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) { return file; } else if (RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED)) {/* www . j a va2 s . co m*/ return new File(file, Constants.DOT_GIT); } file = file.getParentFile(); } } return null; }
From source file:org.eclipse.orion.server.git.servlets.GitUtils.java
License:Open Source License
public static Map<IPath, File> getGitDirs(IPath path, Traverse traverse) throws CoreException { IPath p = path.removeFirstSegments(1); IFileStore fileStore = NewFileServlet.getFileStore(p); if (fileStore == null) return null; File file = fileStore.toLocalFile(EFS.NONE, null); Map<IPath, File> result = new HashMap<IPath, File>(); switch (traverse) { case CURRENT: if (RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) { result.put(new Path(""), file); //$NON-NLS-1$ } else if (RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED)) { result.put(new Path(""), new File(file, Constants.DOT_GIT)); //$NON-NLS-1$ }/* w w w . j a v a 2s.c o m*/ break; case GO_UP: getGitDirsInParents(file, result); break; case GO_DOWN: getGitDirsInChildren(path, result); break; } return result; }
From source file:org.eclipse.orion.server.git.servlets.GitUtils.java
License:Open Source License
private static void getGitDirsInParents(File file, Map<IPath, File> gitDirs) { int levelUp = 0; while (file != null) { if (file.exists()) { if (RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) { gitDirs.put(getPathForLevelUp(levelUp), file); return; } else if (RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED)) {/*from w ww. j av a2 s.c om*/ gitDirs.put(getPathForLevelUp(levelUp), new File(file, Constants.DOT_GIT)); return; } } file = file.getParentFile(); levelUp++; } return; }
From source file:org.eclipse.orion.server.git.servlets.GitUtils.java
License:Open Source License
private static void getGitDirsInChildren(IPath path, Map<IPath, File> gitDirs) throws CoreException { if (WebProject.exists(path.segment(0))) { WebProject webProject = WebProject.fromId(path.segment(0)); IFileStore store = webProject.getProjectStore().getFileStore(path.removeFirstSegments(1)); File file = store.toLocalFile(EFS.NONE, null); if (file.exists() && file.isDirectory()) { if (RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) { gitDirs.put(path.addTrailingSeparator(), file); return; } else if (RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED)) {/* w w w . j a va2 s . com*/ gitDirs.put(path.addTrailingSeparator(), new File(file, Constants.DOT_GIT)); return; } File[] folders = file.listFiles(new FileFilter() { public boolean accept(File file) { return file.isDirectory() && !file.getName().equals(Constants.DOT_GIT); } }); for (File folder : folders) { getGitDirsInChildren(path.append(folder.getName()), gitDirs); } return; } } }
From source file:org.eclipse.orion.server.tests.filesystem.git.GitFileStoreTest.java
License:Open Source License
private void ensureSharedExists(GitFileStore root, boolean empty) { try {//w w w. jav a 2 s .c o m if (empty) { String path = decodeLocalPath(root.getUrl().toString()); File sharedRepo = new File(path); // TODO: can init only local repositories // checking if the folder exists may not be enough though if (!sharedRepo.exists()) { sharedRepo.mkdir(); FileRepository repository = new FileRepository(new File(sharedRepo, Constants.DOT_GIT)); repository.create(true); } } else { // clone to private space: // mkdir will init the shared repo with .gitignore file, see // GitFileStore.initCloneCommitPush(IProgressMonitor) root.mkdir(EFS.NONE, null); // remove private clone FileSystemHelper.clear(root.getLocalFile()); } assertFalse(root.isCloned()); } catch (IOException e) { CoreTest.fail("ensureExists", e); } catch (CoreException e) { CoreTest.fail("ensureExists", e); } }