snap --version= to auto-upgrade

This makes --version=6 still work, despite v6 not being in
supportedVersions. Which is useful for scripts that use it.

I didn't document it on the man page, because it's indistinguishable
from an automatic upgrade after initting as v6.
This commit is contained in:
Joey Hess 2018-10-26 11:44:05 -04:00
parent 636f4a68a9
commit 9f87133bf5
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 7 additions and 1 deletions

View file

@ -42,6 +42,8 @@ git-annex (7.20181025) UNRELEASED; urgency=medium
get confused about whether a locked file's content was present.
* Fix concurrency bug that occurred on the first download from an
exporttree remote.
* init --version=6 will still work, but the repository is auto-upgraded
immediately to v7.
-- Joey Hess <id@joeyh.name> Sat, 13 Oct 2018 00:52:02 -0400

View file

@ -12,6 +12,8 @@ import Annex.Init
import Annex.Version
import Types.RepoVersion
import qualified Annex.SpecialRemote
import qualified Data.Map as M
cmd :: Command
cmd = dontCheck repoExists $
@ -36,7 +38,9 @@ parseRepoVersion s = case RepoVersion <$> readish s of
Nothing -> fail $ "version parse error"
Just v
| v `elem` supportedVersions -> return v
| otherwise -> fail $ s ++ " is not a currently supported repository version"
| otherwise -> case M.lookup v autoUpgradeableVersions of
Just v' -> return v'
Nothing -> fail $ s ++ " is not a currently supported repository version"
seek :: InitOptions -> CommandSeek
seek = commandAction . start