List of usage examples for org.eclipse.jgit.hooks PreCommitHook NAME
String NAME
To view the source code for org.eclipse.jgit.hooks PreCommitHook NAME.
Click Source Link
From source file:org.uberfire.java.nio.fs.jgit.JGitCloneTest.java
License:Apache License
@Test public void testCloneWithHookDir() throws IOException, GitAPIException { final File hooksDir = createTempDirectory(); writeMockHook(hooksDir, PostCommitHook.NAME); writeMockHook(hooksDir, PreCommitHook.NAME); final File parentFolder = createTempDirectory(); final File gitSource = new File(parentFolder, SOURCE_GIT + ".git"); final File gitTarget = new File(parentFolder, TARGET_GIT + ".git"); final Git origin = setupGitRepo(gitSource, hooksDir); final Git cloned = new Clone(gitTarget, gitSource.getAbsolutePath(), false, null, CredentialsProvider.getDefault(), null, hooksDir, true).execute().get(); assertThat(cloned).isNotNull();//from w w w. j a va 2 s . c o m assertThat(new ListRefs(cloned.getRepository()).execute()).hasSize(2); assertEquals(new ListRefs(cloned.getRepository()).execute().size(), new ListRefs(origin.getRepository()).execute().size()); assertThat(new ListRefs(cloned.getRepository()).execute().get(0).getName()).isEqualTo("refs/heads/master"); assertThat(new ListRefs(cloned.getRepository()).execute().get(1).getName()) .isEqualTo("refs/heads/user_branch"); boolean foundPreCommitHook = false; boolean foundPostCommitHook = false; File[] hooks = new File(cloned.getRepository().getDirectory(), "hooks").listFiles(); assertThat(hooks).isNotEmpty().isNotNull(); assertThat(hooks.length).isEqualTo(2); for (File hook : hooks) { if (hook.getName().equals(PreCommitHook.NAME)) { foundPreCommitHook = hook.canExecute(); } else if (hook.getName().equals(PostCommitHook.NAME)) { foundPostCommitHook = hook.canExecute(); } } assertThat(foundPreCommitHook).isTrue(); assertThat(foundPostCommitHook).isTrue(); }
From source file:org.uberfire.java.nio.fs.jgit.JGitFileSystemImplProviderHookTest.java
License:Apache License
@Override public Map<String, String> getGitPreferences() { Map<String, String> gitPrefs = super.getGitPreferences(); try {//from w w w . j a v a2 s .c o m final File hooksDir = createTempDirectory(); gitPrefs.put("org.uberfire.nio.git.hooks", hooksDir.getAbsolutePath()); writeMockHook(hooksDir, "post-commit"); writeMockHook(hooksDir, PreCommitHook.NAME); } catch (IOException e) { e.printStackTrace(); } return gitPrefs; }
From source file:org.uberfire.java.nio.fs.jgit.JGitFileSystemProviderHookTest.java
License:Apache License
@Override public Map<String, String> getGitPreferences() { Map<String, String> gitPrefs = super.getGitPreferences(); gitPrefs.put("org.uberfire.nio.git.daemon.enabled", "true"); int gitDaemonPort = findFreePort(); gitPrefs.put("org.uberfire.nio.git.daemon.port", String.valueOf(gitDaemonPort)); try {//from w ww.j a v a2 s .co m final File hooksDir = createTempDirectory(); gitPrefs.put("org.uberfire.nio.git.hooks", hooksDir.getAbsolutePath()); writeMockHook(hooksDir, "post-commit"); writeMockHook(hooksDir, PreCommitHook.NAME); } catch (IOException e) { e.printStackTrace(); } return gitPrefs; }
From source file:org.uberfire.java.nio.fs.jgit.JGitSubdirectoryCloneTest.java
License:Apache License
@Test public void cloneSubdirectoryWithHookDir() throws Exception { final File hooksDir = createTempDirectory(); writeMockHook(hooksDir, PostCommitHook.NAME); writeMockHook(hooksDir, PreCommitHook.NAME); final File parentFolder = createTempDirectory(); final File sourceDir = new File(parentFolder, SOURCE_GIT + ".git"); final File targetDir = new File(parentFolder, TARGET_GIT + ".git"); final Git origin = gitRepo(sourceDir); commit(origin, "master", "first", content("dir1/file.txt", "foo")); commit(origin, "master", "second", content("dir2/file2.txt", "bar")); commit(origin, "master", "third", content("file3.txt", "moogah")); final Git cloned = new SubdirectoryClone(targetDir, sourceDir.getAbsoluteFile().toURI().toString(), "dir1", singletonList("master"), CredentialsProvider.getDefault(), null, hooksDir).execute(); assertThat(origin.getRepository().getRemoteNames()).isEmpty(); assertThat(cloned).isNotNull();//from w ww . j av a2 s . co m assertThat(listRefs(cloned)).hasSize(1); final List<RevCommit> cloneCommits = getCommits(cloned, "master"); assertThat(cloneCommits).hasSize(1); final RevCommit clonedCommit = cloneCommits.get(0); final RevCommit originCommit = getCommits(origin, "master").get(2); // Ordered children first assertClonedCommitData(origin, "dir1", clonedCommit, originCommit); boolean foundPreCommitHook = false; boolean foundPostCommitHook = false; File[] hooks = new File(cloned.getRepository().getDirectory(), "hooks").listFiles(); assertThat(hooks).isNotEmpty().isNotNull(); assertThat(hooks.length).isEqualTo(2); for (File hook : hooks) { if (hook.getName().equals(PreCommitHook.NAME)) { foundPreCommitHook = hook.canExecute(); } else if (hook.getName().equals(PostCommitHook.NAME)) { foundPostCommitHook = hook.canExecute(); } } assertThat(foundPreCommitHook).isTrue(); assertThat(foundPostCommitHook).isTrue(); }