summaryrefslogtreecommitdiff
path: root/Core.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-27 14:33:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-27 14:33:44 -0400
commit563484e1354878df4a6877e4506af0d70e41b13e (patch)
tree119b65ec7fa76f1f6a72c25739f48bce1a58c146 /Core.hs
parent3281a1cb19e25f964ca9b91877a194fcb216ca5d (diff)
pre-commit hook
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. -}