Java Code Examples for org.eclipse.jgit.lib.Repository#getWorkTree()
The following examples show how to use
org.eclipse.jgit.lib.Repository#getWorkTree() .
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: SubmoduleStatusCommand.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected void run () throws GitException { Repository repository = getRepository(); File workTree = repository.getWorkTree(); org.eclipse.jgit.api.SubmoduleStatusCommand cmd = new Git(repository).submoduleStatus(); for (String path : Utils.getRelativePaths(workTree, roots)) { cmd.addPath(path); } try { Map<String, SubmoduleStatus> result = cmd.call(); GitClassFactory fac = getClassFactory(); for (Map.Entry<String, SubmoduleStatus> e : result.entrySet()) { File root = new File(workTree, e.getKey()); statuses.put(root, fac.createSubmoduleStatus(e.getValue(), root)); } } catch (GitAPIException | JGitInternalException ex) { throw new GitException(ex); } }
Example 2
Source File: SubmoduleInitializeCommand.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected void run () throws GitException { Repository repository = getRepository(); File workTree = repository.getWorkTree(); org.eclipse.jgit.api.SubmoduleInitCommand cmd = new Git(repository).submoduleInit(); for (String path : Utils.getRelativePaths(workTree, roots)) { cmd.addPath(path); } try { cmd.call(); statusCmd.run(); } catch (GitAPIException | JGitInternalException ex) { throw new GitException(ex); } }
Example 3
Source File: GitContentRepository.java From studio with GNU General Public License v3.0 | 5 votes |
@Override public void lockItem(String site, String path) { Repository repo = helper.getRepository(site, StringUtils.isEmpty(site) ? GLOBAL : SANDBOX); synchronized (helper.getRepository(site, StringUtils.isEmpty(site) ? GLOBAL : SANDBOX)) { try (TreeWalk tw = new TreeWalk(repo)) { RevTree tree = helper.getTreeForLastCommit(repo); tw.addTree(tree); // tree ‘0’ tw.setRecursive(false); tw.setFilter(PathFilter.create(path)); if (!tw.next()) { return; } File repoRoot = repo.getWorkTree(); Paths.get(repoRoot.getPath(), tw.getPathString()); File file = new File(tw.getPathString()); LockFile lock = new LockFile(file); lock.lock(); tw.close(); } catch (IOException e) { logger.error("Error while locking file for site: " + site + " path: " + path, e); } } }
Example 4
Source File: GitContentRepository.java From studio with GNU General Public License v3.0 | 5 votes |
@Override public void lockItemForPublishing(String site, String path) { Repository repo = helper.getRepository(site, PUBLISHED); synchronized (repo) { try (TreeWalk tw = new TreeWalk(repo)) { RevTree tree = helper.getTreeForLastCommit(repo); tw.addTree(tree); // tree ‘0’ tw.setRecursive(false); tw.setFilter(PathFilter.create(path)); if (!tw.next()) { return; } File repoRoot = repo.getWorkTree(); Paths.get(repoRoot.getPath(), tw.getPathString()); File file = new File(tw.getPathString()); LockFile lock = new LockFile(file); lock.lock(); tw.close(); } catch (IOException e) { logger.error("Error while locking file for site: " + site + " path: " + path, e); } } }
Example 5
Source File: GitContentRepository.java From studio with GNU General Public License v3.0 | 5 votes |
@Override public void unLockItem(String site, String path) { Repository repo = helper.getRepository(site, StringUtils.isEmpty(site) ? GLOBAL : SANDBOX); synchronized (helper.getRepository(site, StringUtils.isEmpty(site) ? GLOBAL : SANDBOX)) { try (TreeWalk tw = new TreeWalk(repo)) { RevTree tree = helper.getTreeForLastCommit(repo); tw.addTree(tree); // tree ‘0’ tw.setRecursive(false); tw.setFilter(PathFilter.create(path)); if (!tw.next()) { return; } File repoRoot = repo.getWorkTree(); Paths.get(repoRoot.getPath(), tw.getPathString()); File file = new File(tw.getPathString()); LockFile lock = new LockFile(file); lock.unlock(); tw.close(); } catch (IOException e) { logger.error("Error while unlocking file for site: " + site + " path: " + path, e); } } }
Example 6
Source File: GitContentRepository.java From studio with GNU General Public License v3.0 | 5 votes |
@Override public void unLockItemForPublishing(String site, String path) { Repository repo = helper.getRepository(site, PUBLISHED); synchronized (repo) { try (TreeWalk tw = new TreeWalk(repo)) { RevTree tree = helper.getTreeForLastCommit(repo); tw.addTree(tree); // tree ‘0’ tw.setRecursive(false); tw.setFilter(PathFilter.create(path)); if (!tw.next()) { return; } File repoRoot = repo.getWorkTree(); Paths.get(repoRoot.getPath(), tw.getPathString()); File file = new File(tw.getPathString()); LockFile lock = new LockFile(file); lock.unlock(); tw.close(); } catch (IOException e) { logger.error("Error while unlocking file for site: " + site + " path: " + path, e); } } }
Example 7
Source File: GitSubmoduleHandlerV1.java From orion.server with Eclipse Public License 1.0 | 4 votes |
private static StoredConfig getGitSubmodulesConfig( Repository repository ) throws IOException, ConfigInvalidException { File gitSubmodulesFile = new File( repository.getWorkTree(), DOT_GIT_MODULES ); FileBasedConfig gitSubmodulesConfig = new FileBasedConfig( null, gitSubmodulesFile, FS.DETECTED ); gitSubmodulesConfig.load(); return gitSubmodulesConfig; }
Example 8
Source File: RemotingTest.java From git-client-plugin with MIT License | 4 votes |
@Override public FilePath invoke(Repository repo, VirtualChannel channel) { assertNotNull(repo); return new FilePath(repo.getWorkTree()); }