summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-15 17:17:13 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-15 17:17:13 -0400
commit42710158e49f8460ac50b6a77d317b2f6cda4b57 (patch)
tree627f5546fe591df3191a0dbc287a8262ef70efcd /Command
parent49983aafdc36f21aee6aef9a540ac93d7171ab69 (diff)
Use git-annex init --version=6 to get v6 for now
Not ready to make it default because of the direct mode upgrade needing to all happen at once.
Diffstat (limited to 'Command')
-rw-r--r--Command/ConfigList.hs2
-rw-r--r--Command/Init.hs43
-rw-r--r--Command/Reinit.hs2
3 files changed, 33 insertions, 14 deletions
diff --git a/Command/ConfigList.hs b/Command/ConfigList.hs
index 46c909107..997016e8e 100644
--- a/Command/ConfigList.hs
+++ b/Command/ConfigList.hs
@@ -46,7 +46,7 @@ findOrGenUUID = do
else ifM (Annex.Branch.hasSibling <||> (isJust <$> Fields.getField Fields.autoInit))
( do
liftIO checkNotReadOnly
- initialize Nothing
+ initialize Nothing Nothing
getUUID
, return NoUUID
)
diff --git a/Command/Init.hs b/Command/Init.hs
index d969669f8..94d8168a6 100644
--- a/Command/Init.hs
+++ b/Command/Init.hs
@@ -10,25 +10,44 @@ module Command.Init where
import Common.Annex
import Command
import Annex.Init
+import Annex.Version
import qualified Annex.SpecialRemote
cmd :: Command
cmd = dontCheck repoExists $
command "init" SectionSetup "initialize git-annex"
- paramDesc (withParams seek)
+ paramDesc (seek <$$> optParser)
-seek :: CmdParams -> CommandSeek
-seek = withWords start
+data InitOptions = InitOptions
+ { initDesc :: String
+ , initVersion :: Maybe Version
+ }
-start :: [String] -> CommandStart
-start ws = do
- showStart "init" description
- next $ perform description
- where
- description = unwords ws
+optParser :: CmdParamsDesc -> Parser InitOptions
+optParser desc = InitOptions
+ <$> (unwords <$> cmdParams desc)
+ <*> optional (option (str >>= parseVersion)
+ ( long "version" <> metavar paramValue
+ <> help "Override default annex.version"
+ ))
-perform :: String -> CommandPerform
-perform description = do
- initialize $ if null description then Nothing else Just description
+parseVersion :: Monad m => String -> m Version
+parseVersion v
+ | v `elem` supportedVersions = return v
+ | otherwise = fail $ v ++ " is not a currently supported repository version"
+
+seek :: InitOptions -> CommandSeek
+seek = commandAction . start
+
+start :: InitOptions -> CommandStart
+start os = do
+ showStart "init" (initDesc os)
+ next $ perform os
+
+perform :: InitOptions -> CommandPerform
+perform os = do
+ initialize
+ (if null (initDesc os) then Nothing else Just (initDesc os))
+ (initVersion os)
Annex.SpecialRemote.autoEnable
next $ return True
diff --git a/Command/Reinit.hs b/Command/Reinit.hs
index 1be692871..e2c00a3d2 100644
--- a/Command/Reinit.hs
+++ b/Command/Reinit.hs
@@ -38,6 +38,6 @@ perform s = do
then return $ toUUID s
else Remote.nameToUUID s
storeUUID u
- initialize'
+ initialize' Nothing
Annex.SpecialRemote.autoEnable
next $ return True