summaryrefslogtreecommitdiff
path: root/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-03-14 12:01:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-03-14 12:01:56 -0400
commitcaf97fcffd0a1e934fef60c0cae878ee3813f81f (patch)
tree1e2d900df40934a3672b48fb33ad570f01841573 /Git.hs
parent59e2feeda146bd37057db42862c4a4efbaf6e95e (diff)
git-annex-shell: Runs hooks/annex-content after content is received or dropped.
Diffstat (limited to 'Git.hs')
-rw-r--r--Git.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/Git.hs b/Git.hs
index 284bf331c..043cda5ea 100644
--- a/Git.hs
+++ b/Git.hs
@@ -24,12 +24,14 @@ module Git (
gitDir,
configTrue,
attributes,
+ hookPath,
assertLocal,
) where
import qualified Data.Map as M
import Data.Char
import Network.URI (uriPath, uriScheme, unEscapeString)
+import System.Directory
import Common
import Git.Types
@@ -93,17 +95,25 @@ configBare repo = maybe unknown (fromMaybe False . configTrue) $
" is a bare repository; config not read"
{- Path to a repository's gitattributes file. -}
-attributes :: Repo -> String
+attributes :: Repo -> FilePath
attributes repo
| configBare repo = workTree repo ++ "/info/.gitattributes"
| otherwise = workTree repo ++ "/.gitattributes"
{- Path to a repository's .git directory. -}
-gitDir :: Repo -> String
+gitDir :: Repo -> FilePath
gitDir repo
| configBare repo = workTree repo
| otherwise = workTree repo </> ".git"
+{- Path to a given hook script in a repository, only if the hook exists
+ - and is executable. -}
+hookPath :: String -> Repo -> IO (Maybe FilePath)
+hookPath script repo = do
+ let hook = gitDir repo </> "hooks" </> script
+ ok <- doesFileExist hook
+ return $ if ok then Just hook else Nothing
+
{- Path to a repository's --work-tree, that is, its top.
-
- Note that for URL repositories, this is the path on the remote host. -}