summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.java7
diff options
context:
space:
mode:
authorLaurent Goubet <laurent.goubet@obeo.fr>2014-10-31 14:58:07 +0100
committerChristian Halstrick <christian.halstrick@sap.com>2015-02-02 10:22:53 +0100
commit6aed51e3cea6f7114b42bcbc4f66abb48e6ae490 (patch)
tree05521323d215b1a5eefc2541499788925f152990 /org.eclipse.jgit.java7
parentf5936405a3a66b821f716e551de6ee4c1c33ca0b (diff)
downloadjgit-6aed51e3cea6f7114b42bcbc4f66abb48e6ae490.tar.gz
jgit-6aed51e3cea6f7114b42bcbc4f66abb48e6ae490.zip
Introduce hook support into the FS implementations
This introduces the background plumbing necessary to run git hooks from JGit. This implementation will be OS-dependent as it aims to be compatible with existing hooks, mostly written in Shell. It is compatible with unix systems and windows as long as an Unix emulator such as Cygwin is in its PATH. Change-Id: I1f82a5205138fd8032614dd5b52aef14e02238ed Signed-off-by: Laurent Goubet <laurent.goubet@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.java7')
-rw-r--r--org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java16
-rw-r--r--org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_Win32_Java7Cygwin.java18
2 files changed, 34 insertions, 0 deletions
diff --git a/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java b/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java
index 4a73a9bcf5..300cf93bc8 100644
--- a/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java
+++ b/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java
@@ -53,6 +53,9 @@ import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Repository;
+
/**
* FS implementation for Java7 on unix like systems
*/
@@ -344,4 +347,17 @@ public class FS_POSIX_Java7 extends FS_POSIX {
public String normalize(String name) {
return FileUtil.normalize(name);
}
+
+ /**
+ * @since 3.7
+ */
+ @Override
+ public File findHook(Repository repository, Hook hook) {
+ final File gitdir = repository.getDirectory();
+ final Path hookPath = gitdir.toPath().resolve(Constants.HOOKS)
+ .resolve(hook.getName());
+ if (Files.isExecutable(hookPath))
+ return hookPath.toFile();
+ return null;
+ }
}
diff --git a/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_Win32_Java7Cygwin.java b/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_Win32_Java7Cygwin.java
index e40d7cf0b5..b6e5d93885 100644
--- a/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_Win32_Java7Cygwin.java
+++ b/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_Win32_Java7Cygwin.java
@@ -45,6 +45,11 @@ package org.eclipse.jgit.util;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Repository;
/**
* FS for Java7 on Windows with Cygwin
@@ -135,4 +140,17 @@ public class FS_Win32_Java7Cygwin extends FS_Win32_Cygwin {
public Attributes getAttributes(File path) {
return FileUtil.getFileAttributesBasic(this, path);
}
+
+ /**
+ * @since 3.7
+ */
+ @Override
+ public File findHook(Repository repository, Hook hook) {
+ final File gitdir = repository.getDirectory();
+ final Path hookPath = gitdir.toPath().resolve(Constants.HOOKS)
+ .resolve(hook.getName());
+ if (Files.isExecutable(hookPath))
+ return hookPath.toFile();
+ return null;
+ }
}