local git remote autoinit improvements
* Improve display of problems auto-initializing or upgrading local git remotes. * When a local git remote cannot be initialized because it has no git-annex branch or a .noannex file, avoid displaying a message about it.
This commit is contained in:
parent
9f61cb94c0
commit
a76b1ba3d6
3 changed files with 27 additions and 2 deletions
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
module Annex.Init (
|
module Annex.Init (
|
||||||
ensureInitialized,
|
ensureInitialized,
|
||||||
|
autoInitialize,
|
||||||
isInitialized,
|
isInitialized,
|
||||||
initialize,
|
initialize,
|
||||||
initialize',
|
initialize',
|
||||||
|
@ -61,7 +62,7 @@ import qualified Data.Map as M
|
||||||
import Control.Concurrent.Async
|
import Control.Concurrent.Async
|
||||||
|
|
||||||
checkCanInitialize :: Annex a -> Annex a
|
checkCanInitialize :: Annex a -> Annex a
|
||||||
checkCanInitialize a = inRepo (noAnnexFileContent . fmap fromRawFilePath . Git.repoWorkTree) >>= \case
|
checkCanInitialize a = canInitialize' >>= \case
|
||||||
Nothing -> a
|
Nothing -> a
|
||||||
Just noannexmsg -> do
|
Just noannexmsg -> do
|
||||||
warning "Initialization prevented by .noannex file (remove the file to override)"
|
warning "Initialization prevented by .noannex file (remove the file to override)"
|
||||||
|
@ -69,6 +70,12 @@ checkCanInitialize a = inRepo (noAnnexFileContent . fmap fromRawFilePath . Git.r
|
||||||
warning noannexmsg
|
warning noannexmsg
|
||||||
giveup "Not initialized."
|
giveup "Not initialized."
|
||||||
|
|
||||||
|
canInitialize :: Annex Bool
|
||||||
|
canInitialize = isNothing <$> canInitialize'
|
||||||
|
|
||||||
|
canInitialize' :: Annex (Maybe String)
|
||||||
|
canInitialize' = inRepo (noAnnexFileContent . fmap fromRawFilePath . Git.repoWorkTree)
|
||||||
|
|
||||||
genDescription :: Maybe String -> Annex UUIDDesc
|
genDescription :: Maybe String -> Annex UUIDDesc
|
||||||
genDescription (Just d) = return $ UUIDDesc $ encodeBS d
|
genDescription (Just d) = return $ UUIDDesc $ encodeBS d
|
||||||
genDescription Nothing = do
|
genDescription Nothing = do
|
||||||
|
@ -160,6 +167,17 @@ ensureInitialized = getVersion >>= maybe needsinit checkUpgrade
|
||||||
, giveup "First run: git-annex init"
|
, giveup "First run: git-annex init"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
{- Initialize if it can do so automatically.
|
||||||
|
-
|
||||||
|
- Checks repository version and handles upgrades too.
|
||||||
|
-}
|
||||||
|
autoInitialize :: Annex ()
|
||||||
|
autoInitialize = getVersion >>= maybe needsinit checkUpgrade
|
||||||
|
where
|
||||||
|
needsinit = whenM (canInitialize <&&> Annex.Branch.hasSibling) $ do
|
||||||
|
initialize Nothing Nothing
|
||||||
|
autoEnableSpecialRemotes
|
||||||
|
|
||||||
{- Checks if a repository is initialized. Does not check version for ugrade. -}
|
{- Checks if a repository is initialized. Does not check version for ugrade. -}
|
||||||
isInitialized :: Annex Bool
|
isInitialized :: Annex Bool
|
||||||
isInitialized = maybe Annex.Branch.hasSibling (const $ return True) =<< getVersion
|
isInitialized = maybe Annex.Branch.hasSibling (const $ return True) =<< getVersion
|
||||||
|
|
|
@ -35,6 +35,11 @@ git-annex (8.20200523) UNRELEASED; urgency=medium
|
||||||
* import: Avoid using some strange names for temporary keys.
|
* import: Avoid using some strange names for temporary keys.
|
||||||
* S3: The REDUCED_REDUNDANCY storage class is no longer cheaper so
|
* S3: The REDUCED_REDUNDANCY storage class is no longer cheaper so
|
||||||
stop documenting it, and stop offering it as a choice in the assistant.
|
stop documenting it, and stop offering it as a choice in the assistant.
|
||||||
|
* Improve display of problems auto-initializing or upgrading local git
|
||||||
|
remotes.
|
||||||
|
* When a local git remote cannot be initialized because it has no
|
||||||
|
git-annex branch or a .noannex file, avoid displaying a message about it.
|
||||||
|
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Tue, 26 May 2020 10:20:52 -0400
|
-- Joey Hess <id@joeyh.name> Tue, 26 May 2020 10:20:52 -0400
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,9 @@ tryGitConfigRead autoinit r hasuuid
|
||||||
readlocalannexconfig = do
|
readlocalannexconfig = do
|
||||||
let check = do
|
let check = do
|
||||||
Annex.BranchState.disableUpdate
|
Annex.BranchState.disableUpdate
|
||||||
catchNonAsync ensureInitialized (warning . show)
|
catchNonAsync autoInitialize $ \e ->
|
||||||
|
warning $ "remote " ++ Git.repoDescribe r ++
|
||||||
|
" :" ++ show e
|
||||||
Annex.getState Annex.repo
|
Annex.getState Annex.repo
|
||||||
s <- Annex.new r
|
s <- Annex.new r
|
||||||
Annex.eval s $ check `finally` stopCoProcesses
|
Annex.eval s $ check `finally` stopCoProcesses
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue