summaryrefslogtreecommitdiff
path: root/Core.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Core.hs')
-rw-r--r--Core.hs57
1 files changed, 33 insertions, 24 deletions
diff --git a/Core.hs b/Core.hs
index 644bedd00..5182a6855 100644
--- a/Core.hs
+++ b/Core.hs
@@ -11,34 +11,43 @@ import UUID
import qualified GitRepo as Git
import qualified Annex
-{- Sets up a git repo for git-annex. May be called repeatedly. -}
-gitSetup :: Annex ()
-gitSetup = do
+{- Sets up a git repo for git-annex. -}
+setup :: Annex ()
+setup = do
g <- Annex.gitRepo
- liftIO $ setupattributes g
+ liftIO $ gitAttributes g
prepUUID
- where
- -- configure git to use union merge driver on state files
- setupattributes repo = do
- exists <- doesFileExist attributes
- if (not exists)
+
+{- When git-annex is done, it runs this. -}
+shutdown :: Annex ()
+shutdown = do
+ g <- Annex.gitRepo
+ liftIO $ Git.run g ["commit", "-m",
+ "git-annex log update", ".git-annex"]
+
+{- configure git to use union merge driver on state files, if it is not
+ - already -}
+gitAttributes :: Git.Repo -> IO ()
+gitAttributes repo = do
+ exists <- doesFileExist attributes
+ if (not exists)
+ then do
+ writeFile attributes $ attrLine ++ "\n"
+ commit
+ else do
+ content <- readFile attributes
+ if (all (/= attrLine) (lines content))
then do
- writeFile attributes $ attrLine ++ "\n"
+ appendFile attributes $ attrLine ++ "\n"
commit
- else do
- content <- readFile attributes
- if (all (/= attrLine) (lines content))
- then do
- appendFile attributes $ attrLine ++ "\n"
- commit
- else return ()
- where
- attrLine = stateLoc ++ "/*.log merge=union"
- attributes = Git.attributes repo
- commit = do
- Git.run repo ["add", attributes]
- Git.run repo ["commit", "-m", "git-annex setup",
- attributes]
+ else return ()
+ where
+ attrLine = stateLoc ++ "/*.log merge=union"
+ attributes = Git.attributes repo
+ commit = do
+ Git.run repo ["add", attributes]
+ Git.run repo ["commit", "-m", "git-annex setup",
+ attributes]
{- Checks if a given key is currently present in the annexLocation -}
inAnnex :: Backend -> Key -> Annex Bool