Java Code Examples for org.eclipse.jgit.lib.Constants#DOT_GIT
The following examples show how to use
org.eclipse.jgit.lib.Constants#DOT_GIT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitUtils.java From orion.server with Eclipse Public License 1.0 | 6 votes |
/** * Returns the file representing the Git repository directory for the given file path or any of its parent in the filesystem. If the file doesn't exits, is * not a Git repository or an error occurred while transforming the given path into a store <code>null</code> is returned. * * @param file the file to check * @return the .git folder if found or <code>null</code> the give path cannot be resolved to a file or it's not under control of a git repository */ public static File resolveGitDir(File file) { File dot = new File(file, Constants.DOT_GIT); if (RepositoryCache.FileKey.isGitRepository(dot, FS.DETECTED)) { return dot; } else if (dot.isFile()) { try { return getSymRef(file, dot, FS.DETECTED); } catch (IOException ignored) { // Continue searching if gitdir ref isn't found } } else if (RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) { return file; } return null; }
Example 2
Source File: RemoteGitRepositoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Before public void prepareTest() throws Exception { remoteRoot = new File("target", "remote").toPath(); Path repoConfigDir = remoteRoot.resolve("configuration"); Files.createDirectories(repoConfigDir); File baseDir = remoteRoot.toAbsolutePath().toFile(); PathUtil.copyRecursively(getJbossServerBaseDir().resolve("configuration"), repoConfigDir, true); Path properties = repoConfigDir.resolve("logging.properties"); if(Files.exists(properties)) { Files.delete(properties); } File gitDir = new File(baseDir, Constants.DOT_GIT); if (!gitDir.exists()) { try (Git git = Git.init().setDirectory(baseDir).call()) { git.add().addFilepattern("configuration").call(); git.commit().setMessage("Repository initialized").call(); } } remoteRepository = new FileRepositoryBuilder().setWorkTree(baseDir).setGitDir(gitDir).setup().build(); }
Example 3
Source File: GitConfigurationPersister.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public GitConfigurationPersister(GitRepository gitRepository, ConfigurationFile file, QName rootElement, XMLElementReader<List<ModelNode>> rootParser, XMLElementWriter<ModelMarshallingContext> rootDeparser, boolean suppressLoad) { super(file.getBootFile(), rootElement, rootParser, rootDeparser, suppressLoad); root = file.getConfigurationDir().getParentFile().toPath(); mainFile = file.getMainFile(); this.gitRepository = gitRepository; File baseDir = root.toFile(); try { File gitDir = new File(baseDir, Constants.DOT_GIT); if(!gitDir.exists()) { gitDir.mkdir(); } if (gitRepository.isBare()) { Git.init().setDirectory(baseDir).setGitDir(gitDir).call(); ServerLogger.ROOT_LOGGER.gitRespositoryInitialized(baseDir.getAbsolutePath()); } } catch (IllegalStateException | GitAPIException e) { ControllerLogger.ROOT_LOGGER.error(e); } }
Example 4
Source File: RemoteGitPersistenceResourceTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Before public void createDirectoriesAndFiles() throws Exception { root = new File("target", "standalone").toPath(); remoteRoot = new File("target", "remote").toPath().resolve("standalone"); Files.createDirectories(remoteRoot); File baseDir = remoteRoot.toAbsolutePath().toFile(); createFile(remoteRoot, "standard.xml", "std"); File gitDir = new File(baseDir, Constants.DOT_GIT); if (!gitDir.exists()) { try (Git git = Git.init().setDirectory(baseDir).call()) { git.add().addFilepattern("standard.xml").call(); git.commit().setMessage("Repository initialized").call(); } } remoteRepository = new FileRepositoryBuilder().setWorkTree(baseDir).setGitDir(gitDir).setup().build(); repository = new FileRepositoryBuilder().setWorkTree(root.toAbsolutePath().toFile()).setGitDir(new File(root.toAbsolutePath().toFile(), Constants.DOT_GIT)).setup().build(); }
Example 5
Source File: GitCloneTest.java From orion.server with Eclipse Public License 1.0 | 5 votes |
@Test public void testCloneAndLink() throws Exception { createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME); String workspaceId = workspaceIdFromLocation(workspaceLocation); JSONObject project = createProjectOrLink(workspaceLocation, getMethodName().concat("Project"), null); String contentLocation = clone(workspaceId, project).getString(ProtocolConstants.KEY_CONTENT_LOCATION); File contentFile = getRepositoryForContentLocation(contentLocation).getDirectory().getParentFile(); JSONObject newProject = createProjectOrLink(workspaceLocation, getMethodName().concat("-link"), contentFile.toString()); String projectContentLocation = newProject.getString(ProtocolConstants.KEY_CONTENT_LOCATION); // http://<host>/file/<projectId>/ WebRequest request = getGetRequest(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 = getGetRequest(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])); }
Example 6
Source File: AbstractGitRepositoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Before public void prepareEmptyRemoteRepository() throws Exception { emptyRemoteRoot = new File("target", "empty-remote").toPath(); Files.createDirectories(emptyRemoteRoot); File gitDir = new File(emptyRemoteRoot.toFile(), Constants.DOT_GIT); if (!gitDir.exists()) { try (Git git = Git.init().setDirectory(emptyRemoteRoot.toFile()).call()) { } } Assert.assertTrue(gitDir.exists()); emptyRemoteRepository = new FileRepositoryBuilder().setWorkTree(emptyRemoteRoot.toFile()).setGitDir(gitDir).setup().build(); }
Example 7
Source File: GitPersistenceResourceTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Before public void createDirectoriesAndFiles() throws Exception { root = new File("target", "standalone").toPath(); Files.createDirectories(root); File baseDir = root.toAbsolutePath().toFile(); File gitDir = new File(baseDir, Constants.DOT_GIT); if (!gitDir.exists()) { try (Git git = Git.init().setDirectory(baseDir).setGitDir(gitDir).call()) { git.commit().setMessage("Repository initialized").call(); } } repository = new FileRepositoryBuilder().setWorkTree(baseDir).setGitDir(gitDir).setup().build(); }
Example 8
Source File: Utils.java From netbeans with Apache License 2.0 | 4 votes |
public static File getMetadataFolder (File workDir) { return new File(workDir, Constants.DOT_GIT); }