summaryrefslogtreecommitdiff
path: root/Command/Init.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-02 19:04:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-02 19:04:24 -0400
commit0eae5b806c76b0fa3e21fbae6e5f2d9a39a04cce (patch)
tree53aada39ec10bc6217507bce1a9add3b86b3793b /Command/Init.hs
parent606ed6bb3566fa86c1783e3f1c7d799a6f1be8d1 (diff)
broke subcommands out into separate modules
Diffstat (limited to 'Command/Init.hs')
-rw-r--r--Command/Init.hs42
1 files changed, 42 insertions, 0 deletions
diff --git a/Command/Init.hs b/Command/Init.hs
new file mode 100644
index 000000000..b1e4e0e06
--- /dev/null
+++ b/Command/Init.hs
@@ -0,0 +1,42 @@
+{- git-annex command
+ -
+ - Copyright 2010 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Command.Init where
+
+import Control.Monad.State (liftIO)
+import Control.Monad (when)
+
+import Command
+import qualified Annex
+import Core
+import qualified GitRepo as Git
+import UUID
+
+{- Stores description for the repository etc. -}
+start :: SubCmdStartString
+start description = do
+ when (null description) $ error $
+ "please specify a description of this repository\n"
+ showStart "init" description
+ return $ Just $ perform description
+
+perform :: String -> SubCmdPerform
+perform description = do
+ g <- Annex.gitRepo
+ u <- getUUID g
+ describeUUID u description
+ liftIO $ gitAttributes g
+ liftIO $ gitPreCommitHook g
+ return $ Just $ cleanup
+
+cleanup :: SubCmdCleanup
+cleanup = do
+ g <- Annex.gitRepo
+ logfile <- uuidLog
+ liftIO $ Git.run g ["add", logfile]
+ liftIO $ Git.run g ["commit", "-m", "git annex init", logfile]
+ return True