avoid version check before running version and upgrade commands
There are two types of commands; those that access the repository and those that don't. Sorted.
This commit is contained in:
parent
54c39d09ba
commit
140a351fc5
33 changed files with 46 additions and 37 deletions
|
@ -45,7 +45,9 @@ parseCmd argv header cmds options = do
|
|||
[] -> error $ "unknown command" ++ usagemsg
|
||||
[command] -> do
|
||||
_ <- sequence flags
|
||||
prepCmd command (drop 1 params)
|
||||
when (cmdusesrepo command) $
|
||||
checkVersion
|
||||
prepCommand command (drop 1 params)
|
||||
_ -> error "internal error: multiple matching commands"
|
||||
where
|
||||
getopt = case getOpt Permute options argv of
|
||||
|
@ -93,7 +95,6 @@ tryRun' _ errnum [] = do
|
|||
startup :: Annex Bool
|
||||
startup = do
|
||||
prepUUID
|
||||
checkVersion
|
||||
return True
|
||||
|
||||
{- Cleanup actions. -}
|
||||
|
|
13
Command.hs
13
Command.hs
|
@ -61,13 +61,20 @@ data Command = Command {
|
|||
cmdname :: String,
|
||||
cmdparams :: String,
|
||||
cmdseek :: [CommandSeek],
|
||||
cmddesc :: String
|
||||
cmddesc :: String,
|
||||
cmdusesrepo :: Bool
|
||||
}
|
||||
|
||||
repoCommand :: String -> String -> [CommandSeek] -> String -> Command
|
||||
repoCommand n p s d = Command n p s d True
|
||||
|
||||
standaloneCommand :: String -> String -> [CommandSeek] -> String -> Command
|
||||
standaloneCommand n p s d = Command n p s d False
|
||||
|
||||
{- Prepares a list of actions to run to perform a command, based on
|
||||
- the parameters passed to it. -}
|
||||
prepCmd :: Command -> [String] -> Annex [Annex Bool]
|
||||
prepCmd Command { cmdseek = seek } params = do
|
||||
prepCommand :: Command -> [String] -> Annex [Annex Bool]
|
||||
prepCommand Command { cmdseek = seek } params = do
|
||||
lists <- mapM (\s -> s params) seek
|
||||
return $ map doCommand $ concat lists
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import Utility
|
|||
import Touch
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "add" paramPath seek "add files to annex"]
|
||||
command = [repoCommand "add" paramPath seek "add files to annex"]
|
||||
|
||||
{- Add acts on both files not checked into git yet, and unlocked files. -}
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -14,7 +14,7 @@ import Command
|
|||
import UUID
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "configlist" paramNothing seek
|
||||
command = [standaloneCommand "configlist" paramNothing seek
|
||||
"outputs relevant git configuration"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -11,7 +11,7 @@ import Command
|
|||
import qualified Command.Move
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "copy" paramPath seek
|
||||
command = [repoCommand "copy" paramPath seek
|
||||
"copy content of files to/from another repository"]
|
||||
|
||||
-- A copy is just a move that does not delete the source file.
|
||||
|
|
|
@ -16,7 +16,7 @@ import Messages
|
|||
import qualified Command.Init
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "describe" (paramPair paramRemote paramDesc) seek
|
||||
command = [repoCommand "describe" (paramPair paramRemote paramDesc) seek
|
||||
"change description of a repository"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -18,7 +18,7 @@ import Messages
|
|||
import Utility
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "drop" paramPath seek
|
||||
command = [repoCommand "drop" paramPath seek
|
||||
"indicate content of files not currently wanted"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -15,7 +15,7 @@ import Content
|
|||
import Messages
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "dropkey" (paramRepeating paramKey) seek
|
||||
command = [repoCommand "dropkey" (paramRepeating paramKey) seek
|
||||
"drops annexed content for specified keys"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -23,7 +23,7 @@ import Backend
|
|||
import Key
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "dropunused" (paramRepeating paramNumber) seek
|
||||
command = [repoCommand "dropunused" (paramRepeating paramNumber) seek
|
||||
"drop unused file content"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -14,7 +14,7 @@ import Command
|
|||
import Content
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "find" (paramOptional $ paramRepeating paramPath) seek
|
||||
command = [repoCommand "find" (paramOptional $ paramRepeating paramPath) seek
|
||||
"lists available files"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -18,7 +18,7 @@ import Content
|
|||
import Messages
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "fix" paramPath seek
|
||||
command = [repoCommand "fix" paramPath seek
|
||||
"fix up symlinks to point to annexed content"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -21,7 +21,7 @@ import Messages
|
|||
import Key
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "fromkey" paramPath seek
|
||||
command = [repoCommand "fromkey" paramPath seek
|
||||
"adds a file using a specific key"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -20,7 +20,7 @@ import Content
|
|||
import LocationLog
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "fsck" (paramOptional $ paramRepeating paramPath) seek
|
||||
command = [repoCommand "fsck" (paramOptional $ paramRepeating paramPath) seek
|
||||
"check for problems"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -14,7 +14,7 @@ import Content
|
|||
import Messages
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "get" paramPath seek
|
||||
command = [repoCommand "get" paramPath seek
|
||||
"make content of annexed files available"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -14,7 +14,7 @@ import Command
|
|||
import Content
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "inannex" (paramRepeating paramKey) seek
|
||||
command = [repoCommand "inannex" (paramRepeating paramKey) seek
|
||||
"checks if keys are present in the annex"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -23,7 +23,7 @@ import Types
|
|||
import Utility
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "init" paramDesc seek
|
||||
command = [repoCommand "init" paramDesc seek
|
||||
"initialize git-annex with repository description"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -17,7 +17,7 @@ import qualified GitRepo as Git
|
|||
import Utility
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "lock" paramPath seek "undo unlock command"]
|
||||
command = [repoCommand "lock" paramPath seek "undo unlock command"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withFilesUnlocked start]
|
||||
|
|
|
@ -29,7 +29,7 @@ import qualified Dot
|
|||
data Link = Link Git.Repo Git.Repo
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "map" paramNothing seek "generate map of repositories"]
|
||||
command = [repoCommand "map" paramNothing seek "generate map of repositories"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withNothing start]
|
||||
|
|
|
@ -21,7 +21,7 @@ import Messages
|
|||
import qualified Command.Add
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "migrate" paramPath seek "switch data to different backend"]
|
||||
command = [repoCommand "migrate" paramPath seek "switch data to different backend"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withBackendFilesInGit start]
|
||||
|
|
|
@ -22,7 +22,7 @@ import Messages
|
|||
import Utility
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "move" paramPath seek
|
||||
command = [repoCommand "move" paramPath seek
|
||||
"move content of files to/from another repository"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -17,7 +17,7 @@ import qualified Command.Fix
|
|||
import Utility
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "pre-commit" paramPath seek "run by git pre-commit hook"]
|
||||
command = [repoCommand "pre-commit" paramPath seek "run by git pre-commit hook"]
|
||||
|
||||
{- The pre-commit hook needs to fix symlinks to all files being committed.
|
||||
- And, it needs to inject unlocked files into the annex. -}
|
||||
|
|
|
@ -17,7 +17,7 @@ import Content
|
|||
import RsyncFile
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "recvkey" paramKey seek
|
||||
command = [repoCommand "recvkey" paramKey seek
|
||||
"runs rsync in server mode to receive content"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -15,7 +15,7 @@ import Trust
|
|||
import Messages
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "semitrust" (paramRepeating paramRemote) seek
|
||||
command = [repoCommand "semitrust" (paramRepeating paramRemote) seek
|
||||
"return repository to default trust level"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -18,7 +18,7 @@ import Content
|
|||
import RsyncFile
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "sendkey" paramKey seek
|
||||
command = [repoCommand "sendkey" paramKey seek
|
||||
"runs rsync in server mode to send content"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -16,7 +16,7 @@ import Content
|
|||
import Messages
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "setkey" (paramRepeating paramKey) seek
|
||||
command = [repoCommand "setkey" (paramRepeating paramKey) seek
|
||||
"sets annexed content for a key using a temp file"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -15,7 +15,7 @@ import UUID
|
|||
import Messages
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "trust" (paramRepeating paramRemote) seek
|
||||
command = [repoCommand "trust" (paramRepeating paramRemote) seek
|
||||
"trust a repository"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -22,7 +22,7 @@ import qualified GitRepo as Git
|
|||
import Messages
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "unannex" paramPath seek "undo accidential add command"]
|
||||
command = [repoCommand "unannex" paramPath seek "undo accidential add command"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withFilesInGit start]
|
||||
|
|
|
@ -21,7 +21,7 @@ import qualified Command.Unannex
|
|||
import qualified Command.Init
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "uninit" paramPath seek
|
||||
command = [repoCommand "uninit" paramPath seek
|
||||
"de-initialize git-annex and clean out repository"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -22,8 +22,8 @@ import CopyFile
|
|||
|
||||
command :: [Command]
|
||||
command =
|
||||
[ Command "unlock" paramPath seek "unlock files for modification"
|
||||
, Command "edit" paramPath seek "same as unlock"
|
||||
[ repoCommand "unlock" paramPath seek "unlock files for modification"
|
||||
, repoCommand "edit" paramPath seek "same as unlock"
|
||||
]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -15,7 +15,7 @@ import Trust
|
|||
import Messages
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "untrust" (paramRepeating paramRemote) seek
|
||||
command = [repoCommand "untrust" (paramRepeating paramRemote) seek
|
||||
"do not trust a repository"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
|
@ -25,7 +25,8 @@ import qualified GitRepo as Git
|
|||
import qualified Backend
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "unused" paramNothing seek "look for unused file content"]
|
||||
command = [repoCommand "unused" paramNothing seek
|
||||
"look for unused file content"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withNothing start]
|
||||
|
|
|
@ -15,7 +15,7 @@ import qualified SysConfig
|
|||
import Version
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "version" paramNothing seek "show versions"]
|
||||
command = [standaloneCommand "version" paramNothing seek "show version info"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withNothing start]
|
||||
|
|
|
@ -17,7 +17,7 @@ import UUID
|
|||
import Types
|
||||
|
||||
command :: [Command]
|
||||
command = [Command "whereis" (paramOptional $ paramRepeating paramPath) seek
|
||||
command = [repoCommand "whereis" (paramOptional $ paramRepeating paramPath) seek
|
||||
"lists repositories that have file content"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
|
|
Loading…
Add table
Reference in a new issue