/** * @param repo */ protected CustomDiffCommand(Git git) { super(git.getRepository()); this.git = git; }
private DiffFormatter createFormatter() { OutputStream outputStream = new ByteArrayOutputStream(); DiffFormatter formatter = new DiffFormatter(outputStream); formatter.setRepository(git.getRepository()); return formatter; }
/** * @param path A path for a JGit file system. Must not be null. * @return The file path for an niogit directory that contains the given path's filesystem. */ public String getNiogitRepoPath(org.uberfire.java.nio.file.Path path) { try { final JGitPathImpl gPath = (JGitPathImpl) path; final File directory = gPath.getFileSystem().getGit().getRepository().getDirectory(); return directory.toURI().toString(); } catch (ClassCastException cce) { throw new IllegalArgumentException("Cannot get .niogit directory for non-jgit path.", cce); } }
@Override public Repository open(final T client, final String name) throws RepositoryNotFoundException, ServiceNotAuthorizedException, ServiceNotEnabledException, ServiceMayNotContinueException { final JGitFileSystem fs = fsManager.get(name); if (fs == null) { throw new RepositoryNotFoundException(name); } return fs.getGit().getRepository(); }
@Before public void setup() { config = mock(JGitFileSystemProviderConfiguration.class); git = mock(Git.class); when(git.getRepository()).thenReturn(mock(Repository.class)); }
@Before public void setup() { config = mock(JGitFileSystemProviderConfiguration.class); git = mock(Git.class); when(git.getRepository()).thenReturn(mock(Repository.class)); }
private void prepareHook(final Integer code) throws IOException { File destHookFile = fs.getGit().getRepository().getDirectory().toPath().resolve(HOOKS_FOLDER).resolve("post-commit").toFile(); FileUtils.write(destHookFile, SCRIPT + code, Charset.defaultCharset()); Set<PosixFilePermission> perms = new HashSet<>(); perms.add(PosixFilePermission.OWNER_READ); perms.add(PosixFilePermission.OWNER_WRITE); perms.add(PosixFilePermission.GROUP_EXECUTE); perms.add(PosixFilePermission.OTHERS_EXECUTE); perms.add(PosixFilePermission.OWNER_EXECUTE); Files.setPosixFilePermissions(destHookFile.toPath(), perms); }
private void prepareHook(final Integer code) throws IOException { File destHookFile = fs.getGit().getRepository().getDirectory().toPath().resolve(HOOKS_FOLDER).resolve("post-commit").toFile(); FileUtils.write(destHookFile, SCRIPT + code, Charset.defaultCharset()); Set<PosixFilePermission> perms = new HashSet<>(); perms.add(PosixFilePermission.OWNER_READ); perms.add(PosixFilePermission.OWNER_WRITE); perms.add(PosixFilePermission.GROUP_EXECUTE); perms.add(PosixFilePermission.OTHERS_EXECUTE); perms.add(PosixFilePermission.OWNER_EXECUTE); Files.setPosixFilePermissions(destHookFile.toPath(), perms); }
private void removeSpaceDirectory(final Space space) { final URI configPathURI = URI.create(SpacesAPI.resolveConfigFileSystemPath(SpacesAPI.Scheme.DEFAULT, space.getName())); final Path configPath = ioService.get(configPathURI); final JGitPathImpl configGitPath = (JGitPathImpl) configPath; final File spacePath = configGitPath.getFileSystem().getGit().getRepository().getDirectory().getParentFile().getParentFile(); ioService.delete(configPath.getFileSystem().getPath("")); spacePath.delete(); }
private TreeRevFilter createTreeRevFilter(final RevWalk rw, String curPath, final RenameCallback renameCallback) { final FollowFilter followFilter = FollowFilter.create(curPath, git.getRepository().getConfig().get(DiffConfig.KEY)); followFilter.setRenameCallback(renameCallback); final TreeRevFilter revFilter = new TreeRevFilter(rw, followFilter); return revFilter; }
private List<RevCommit> getCommits(final Git git, String branch) throws Exception { List<RevCommit> commits = new ArrayList<>(); try (RevWalk revWalk = new RevWalk(git.getRepository())) { final RevCommit branchTip = revWalk.parseCommit(git.getRepository().resolve(branch)); revWalk.markStart(branchTip); revWalk.sort(RevSort.TOPO); final Iterator<RevCommit> iter = revWalk.iterator(); while (iter.hasNext()) { commits.add(iter.next()); } } return commits; }
@Override public FileStore getFileStore(final Path path) throws IOException, SecurityException { checkNotNull("path", path); return new JGitFileStore(toPathImpl(path).getFileSystem().getGit().getRepository()); }
public RevCommit execute() throws IOException { try (final RevWalk rw = new RevWalk(git.getRepository())) { final RevCommit root = rw.parseCommit(ref.getObjectId()); rw.sort(RevSort.REVERSE); rw.markStart(root); return rw.next(); } catch (final IOException ignored) { } return null; } }
private void postCommitHook(final JGitFileSystem fileSystem) { ProcessResult result = detectedFS.runHookIfPresent(fileSystem.getGit().getRepository(), "post-commit", new String[0]); if(result.getStatus().equals(ProcessResult.Status.OK)) { fileSystem.notifyPostCommit(result.getExitCode()); } }
private RevWalk buildWalk() throws GitAPIException, IOException { final RevWalk rw = new RevWalk(git.getRepository()); rw.setTreeFilter(TreeFilter.ANY_DIFF); rw.markStart(rw.parseCommit(endRange)); rw.sort(RevSort.TOPO); if (startRange != null) { rw.markUninteresting(rw.parseCommit(startRange)); } return rw; }
@Test public void resolveByRepositoryTest() { JGitFileSystem fsSimpleName = ((JGitFileSystemProxy) provider.newFileSystem(URI.create("git://repo"), EMPTY_ENV)).getRealJGitFileSystem(); JGitFileSystemProvider.RepositoryResolverImpl<Object> objectRepositoryResolver = provider.new RepositoryResolverImpl<>(); assertEquals(fsSimpleName, objectRepositoryResolver.resolveFileSystem(fsSimpleName.getGit().getRepository())); JGitFileSystem fsComposedName1 = ((JGitFileSystemProxy) provider.newFileSystem(URI.create("git://user1/dora"), EMPTY_ENV)).getRealJGitFileSystem(); assertEquals(fsComposedName1, objectRepositoryResolver.resolveFileSystem(fsComposedName1.getGit().getRepository())); }
@Test public void resolveByRepositoryTest() { JGitFileSystem fsSimpleName = ((JGitFileSystemProxy) provider.newFileSystem(URI.create("git://repo"), EMPTY_ENV)).getRealJGitFileSystem(); JGitFileSystemProvider.RepositoryResolverImpl<Object> objectRepositoryResolver = provider.new RepositoryResolverImpl<>(); assertEquals(fsSimpleName, objectRepositoryResolver.resolveFileSystem(fsSimpleName.getGit().getRepository())); JGitFileSystem fsComposedName1 = ((JGitFileSystemProxy) provider.newFileSystem(URI.create("git://user1/dora"), EMPTY_ENV)).getRealJGitFileSystem(); assertEquals(fsComposedName1, objectRepositoryResolver.resolveFileSystem(fsComposedName1.getGit().getRepository())); }
@Test public void testForkWithoutHookDirShouldNotBeUpdatedAfterGitHookDirAdded() throws IOException, GitAPIException { final File hooksDir = createTempDirectory(); final File parentFolder = createTempDirectory(); final File gitSource = new File(parentFolder, SOURCE_GIT + ".git"); writeMockHook(hooksDir, PostCommitHook.NAME); writeMockHook(hooksDir, PreCommitHook.NAME); final Git repo = new CreateRepository(gitSource, null).execute().get(); final Git existentRepoWithHookDirDefined = new CreateRepository(gitSource, hooksDir).execute().get(); File[] hooks = new File(existentRepoWithHookDirDefined.getRepository().getDirectory(), "hooks").listFiles(); assertThat(hooks).isEmpty(); }
private Ref branch(Git origin, String source, String target) throws Exception { final Repository repo = origin.getRepository(); return org.eclipse.jgit.api.Git.wrap(repo) .branchCreate() .setName(target) .setStartPoint(source) .call(); }
private Ref branch(Git origin, String source, String target) throws Exception { final Repository repo = origin.getRepository(); return org.eclipse.jgit.api.Git.wrap(repo) .branchCreate() .setName(target) .setStartPoint(source) .call(); }