aboutsummaryrefslogtreecommitdiff
path: root/Command/Reinit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-15 20:13:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-15 20:13:35 -0400
commitdc748c7336aea9cbf04c0311098a44c2b329633d (patch)
tree1a993dd9662ff046b74a427232b8e301500a97b8 /Command/Reinit.hs
parent60c4bcefd4d3001e7025fc59c1f7ab927a3a5c34 (diff)
reinit: New command that can initialize a new reposotory using the configuration of a previously known repository. Useful if a repository got deleted and you want to clone it back the way it was.
Diffstat (limited to 'Command/Reinit.hs')
-rw-r--r--Command/Reinit.hs38
1 files changed, 38 insertions, 0 deletions
diff --git a/Command/Reinit.hs b/Command/Reinit.hs
new file mode 100644
index 000000000..0fc1e8314
--- /dev/null
+++ b/Command/Reinit.hs
@@ -0,0 +1,38 @@
+{- git-annex command
+ -
+ - Copyright 2014 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Command.Reinit where
+
+import Common.Annex
+import Command
+import Annex.Init
+import Annex.UUID
+import Types.UUID
+import qualified Remote
+
+def :: [Command]
+def = [dontCheck repoExists $
+ command "reinit" (paramUUID ++ " or " ++ paramDesc) seek SectionUtility ""]
+
+seek :: CommandSeek
+seek = withWords start
+
+start :: [String] -> CommandStart
+start ws = do
+ showStart "reinit" s
+ next $ perform s
+ where
+ s = unwords ws
+
+perform :: String -> CommandPerform
+perform s = do
+ u <- if isUUID s
+ then return $ toUUID s
+ else Remote.nameToUUID s
+ storeUUID u
+ initialize'
+ next $ return True