summaryrefslogtreecommitdiff
path: root/Core.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Core.hs')
-rw-r--r--Core.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/Core.hs b/Core.hs
index 80bf56cc4..254bcec51 100644
--- a/Core.hs
+++ b/Core.hs
@@ -73,6 +73,21 @@ gitAttributes repo = do
Git.run repo ["commit", "-m", "git-annex setup",
attributes]
+{- set up a git pre-commit hook, if one is not already present -}
+gitPreCommitHook :: Git.Repo -> IO ()
+gitPreCommitHook repo = do
+ let hook = (Git.workTree repo) ++ "/" ++ (Git.dir repo) ++
+ "/hooks/pre-commit"
+ exists <- doesFileExist hook
+ if (exists)
+ then putStrLn $ "pre-commit hook (" ++ hook ++ ") already exists, not configuring"
+ else do
+ writeFile hook $ "#!/bin/sh\n" ++
+ "# automatically configured by git-annex\n" ++
+ "git annex pre-commit .\n"
+ p <- getPermissions hook
+ setPermissions hook $ p {executable = True}
+
{- Checks if a given key is currently present in the annexLocation.
-
- This can be run against a remote repository to check the key there. -}