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.tests.filesystem.git.GitFileStoreTest.java
License:Open Source License
/** * @param url/*from w w w .j a v a 2s . c o m*/ * @see org.eclipse.orion.server.filesystem.git.GitFileStore#initBare() */ void initBare(URL url) throws IOException { String path = decodeLocalPath(url.toString()); File sharedRepo = new File(path); if (!sharedRepo.exists()) { sharedRepo.mkdir(); FileRepository repository = new FileRepository(new File(sharedRepo, Constants.DOT_GIT)); repository.create(true); } }
From source file:org.eclipse.orion.server.tests.servlets.git.GitCloneTest.java
License:Open Source License
@Test public void testCloneAndLink() throws Exception { URI workspaceLocation = createWorkspace(getMethodName()); JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null); IPath clonePath = new Path("file").append(project.getString(ProtocolConstants.KEY_ID)).makeAbsolute(); String contentLocation = clone(clonePath).getString(ProtocolConstants.KEY_CONTENT_LOCATION); File contentFile = getRepositoryForContentLocation(contentLocation).getDirectory().getParentFile(); JSONObject newProject = createProjectOrLink(workspaceLocation, getMethodName() + "-link", contentFile.toString());//from ww w.j a va 2s .co m String projectContentLocation = newProject.getString(ProtocolConstants.KEY_CONTENT_LOCATION); // http://<host>/file/<projectId>/ WebRequest request = getGetFilesRequest(projectContentLocation); WebResponse response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); JSONObject link = new JSONObject(response.getText()); String childrenLocation = link.getString(ProtocolConstants.KEY_CHILDREN_LOCATION); assertNotNull(childrenLocation); // http://<host>/file/<projectId>/?depth=1 request = getGetFilesRequest(childrenLocation); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); List<JSONObject> children = getDirectoryChildren(new JSONObject(response.getText())); String[] expectedChildren = new String[] { Constants.DOT_GIT, "folder", "test.txt" }; assertEquals("Wrong number of directory children", expectedChildren.length, children.size()); assertNotNull(getChildByName(children, expectedChildren[0])); assertNotNull(getChildByName(children, expectedChildren[1])); assertNotNull(getChildByName(children, expectedChildren[2])); }
From source file:org.eclipse.orion.server.tests.servlets.git.GitCloneTest.java
License:Open Source License
@Test public void testCloneOverSshWithPassword() throws Exception { Assume.assumeTrue(sshRepo != null);//from ww w . java2 s . co m Assume.assumeTrue(password != null); Assume.assumeTrue(knownHosts != null); URI workspaceLocation = createWorkspace(getMethodName()); JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null); IPath clonePath = new Path("file").append(project.getString(ProtocolConstants.KEY_ID)).makeAbsolute(); URIish uri = new URIish(sshRepo); WebRequest request = new PostGitCloneRequest().setURIish(uri).setFilePath(clonePath) .setKnownHosts(knownHosts).setPassword(password).getWebRequest(); String contentLocation = clone(request); File file = getRepositoryForContentLocation(contentLocation).getDirectory().getParentFile(); assertTrue(file.exists()); assertTrue(file.isDirectory()); assertTrue(RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED)); }
From source file:org.eclipse.orion.server.tests.servlets.git.GitCloneTest.java
License:Open Source License
@Test public void testCloneOverSshWithPassphraseProtectedKey() throws Exception { Assume.assumeTrue(sshRepo2 != null); Assume.assumeTrue(privateKey != null); Assume.assumeTrue(passphrase != null); URI workspaceLocation = createWorkspace(getMethodName()); JSONObject project = createProjectOrLink(workspaceLocation, getMethodName(), null); IPath clonePath = new Path("file").append(project.getString(ProtocolConstants.KEY_ID)).makeAbsolute(); URIish uri = new URIish(sshRepo2); WebRequest request = new PostGitCloneRequest().setURIish(uri).setFilePath(clonePath) .setKnownHosts(knownHosts2).setPrivateKey(privateKey).setPublicKey(publicKey) .setPassphrase(passphrase).getWebRequest(); String contentLocation = clone(request); File file = getRepositoryForContentLocation(contentLocation).getDirectory().getParentFile(); assertTrue(file.exists());/* www .j a va 2s .c o m*/ assertTrue(file.isDirectory()); assertTrue(RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED)); }
From source file:org.eclipse.orion.server.tests.servlets.git.GitTest.java
License:Open Source License
protected void createRepository() throws IOException, GitAPIException, CoreException { IPath randomLocation = getRandomLocation(); gitDir = randomLocation.toFile();//from w ww .ja v a 2 s . c o m randomLocation = randomLocation.addTrailingSeparator().append(Constants.DOT_GIT); File dotGitDir = randomLocation.toFile().getCanonicalFile(); db = new FileRepository(dotGitDir); assertFalse(dotGitDir.exists()); db.create(false /* non bare */); testFile = new File(gitDir, "test.txt"); testFile.createNewFile(); createFile(testFile.toURI(), "test"); File folder = new File(gitDir, "folder"); folder.mkdir(); File folderFile = new File(folder, "folder.txt"); folderFile.createNewFile(); createFile(folderFile.toURI(), "folder"); Git git = new Git(db); git.add().addFilepattern(".").call(); git.commit().setMessage("Initial commit").call(); }
From source file:org.eclipse.orion.server.tests.servlets.git.GitTest.java
License:Open Source License
protected static Repository getRepositoryForContentLocation(String fileLocation) throws CoreException, IOException { assertFileUri(fileLocation);//from w w w . j a va 2 s . com URI uri = URI.create(fileLocation); IPath path = new Path(uri.getPath()); WebProject.exists(path.segment(1)); WebProject wp = WebProject.fromId(path.segment(1)); IFileStore fsStore = getProjectStore(wp, "test"); fsStore = fsStore.getFileStore(path.removeFirstSegments(2)); File file = new File(fsStore.toURI()); if (RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) { // 'file' is already what we're looking for } else if (RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED)) { file = new File(file, Constants.DOT_GIT); } else { fail(fileLocation + " is not a repository"); } return new FileRepository(file); }
From source file:org.eclipse.orion.server.tests.servlets.git.GitUriTest.java
License:Open Source License
@Test public void testGitUrisInContentLocation() throws Exception { URI workspaceLocation = createWorkspace(getMethodName()); String projectName = getMethodName(); // http://<host>/workspace/<workspaceId>/ JSONObject newProject = createProjectOrLink(workspaceLocation, projectName, gitDir.toString()); String contentLocation = newProject.optString(ProtocolConstants.KEY_CONTENT_LOCATION, null); assertNotNull(contentLocation);/*from w w w . j a v a2 s .c o m*/ // http://<host>/file/<projectId>/ WebRequest request = getGetFilesRequest(contentLocation); WebResponse response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); JSONObject project = new JSONObject(response.getText()); assertGitSectionExists(project); // TODO: it's a linked repo, see bug 346114 // assertCloneUri(gitSection.optString(GitConstants.KEY_CLONE, null)); String childrenLocation = project.getString(ProtocolConstants.KEY_CHILDREN_LOCATION); assertNotNull(childrenLocation); // http://<host>/file/<projectId>/?depth=1 request = getGetFilesRequest(childrenLocation); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); List<JSONObject> children = getDirectoryChildren(new JSONObject(response.getText())); String[] expectedChildren = new String[] { Constants.DOT_GIT, "folder", "test.txt" }; assertEquals("Wrong number of directory children", expectedChildren.length, children.size()); for (JSONObject child : children) { assertGitSectionExists(child); // TODO: it's a linked repo, see bug 346114 // assertCloneUri(gitSection.optString(GitConstants.KEY_CLONE, null)); } childrenLocation = getChildByName(children, "folder").getString(ProtocolConstants.KEY_CHILDREN_LOCATION); // http://<host>/file/<projectId>/folder/?depth=1 request = getGetFilesRequest(childrenLocation); response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); children = getDirectoryChildren(new JSONObject(response.getText())); expectedChildren = new String[] { "folder.txt" }; assertEquals("Wrong number of directory children", expectedChildren.length, children.size()); for (JSONObject child : children) { assertGitSectionExists(child); // TODO: it's a linked repo, see bug 346114 // assertCloneUri(gitSection.optString(GitConstants.KEY_CLONE, null)); } }
From source file:org.eclipse.releng.tests.GitCopyrightAdapterTest.java
License:Open Source License
public void setUp() throws Exception { super.setUp(); db = createWorkRepository();//from w w w. j a va 2 s.c om trash = db.getWorkTree(); gitDir = new File(trash, Constants.DOT_GIT); project = createProject(PROJECT_NAME); file1 = project.getFile(FILE1_NAME); connect(); }
From source file:org.eclipse.releng.tests.LocalDiskRepositoryTest.java
License:Eclipse Distribution License
/** * Creates a new unique directory for a test repository * * @param bare/*from www.j a va 2 s .c o m*/ * true for a bare repository; false for a repository with a * working directory * @return a unique directory for a test repository * @throws IOException */ protected File createUniqueTestGitDir(boolean bare) throws IOException { String gitdirName = createUniqueTestFolderPrefix(); if (!bare) gitdirName += "/"; gitdirName += Constants.DOT_GIT; File gitdir = new File(trash, gitdirName); return gitdir.getCanonicalFile(); }
From source file:org.flowerplatform.web.git.GitUtils.java
License:Open Source License
public File getGitDir(File file) { if (file.exists()) { while (file != null) { if (GIT_REPOSITORIES_NAME.equals(file.getName())) { return null; }/*from w w w . ja va2s. co m*/ if (CommonPlugin.getInstance().getWorkspaceRoot().getName().equals(file.getName())) { return null; } if (RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) { return file; } else if (RepositoryCache.FileKey.isGitRepository(new File(file, Constants.DOT_GIT), FS.DETECTED)) { return new File(file, Constants.DOT_GIT); } file = file.getParentFile(); } } return null; }