summaryrefslogtreecommitdiff
path: root/Core.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-08 14:39:12 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-08 14:39:12 -0400
commitab4de454914954676aa1e05ef26dc8a85bd8f6f1 (patch)
tree17cd1334f17bb15df3d1a1d889e4f99887de9843 /Core.hs
parentf03adec793d378cc4807392400d09e70e293a991 (diff)
Add annex.version, which will be used to automate upgrades.
Diffstat (limited to 'Core.hs')
-rw-r--r--Core.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/Core.hs b/Core.hs
index f34b2ebbe..347e63593 100644
--- a/Core.hs
+++ b/Core.hs
@@ -46,6 +46,7 @@ tryRun' _ errnum [] =
startup :: Annex Bool
startup = do
prepUUID
+ autoUpgrade
return True
{- When git-annex is done, it runs this. -}
@@ -151,6 +152,21 @@ getViaTmp key action = do
-- to resume its transfer
return False
+{- Uses the annex.version git config setting to automate upgrades. -}
+autoUpgrade :: Annex ()
+autoUpgrade = do
+ g <- Annex.gitRepo
+
+ case Git.configGet g field "0" of
+ "0" -> do -- before there was repo versioning
+ setVersion
+ v | v == currentVersion -> return ()
+ _ -> error "this version of git-annex is too old for this git repository!"
+ where
+ currentVersion = "1"
+ setVersion = Annex.setConfig field currentVersion
+ field = "annex.version"
+
{- Output logging -}
verbose :: Annex () -> Annex ()
verbose a = do