diff options
author | Joey Hess <joey@kitenet.net> | 2014-03-26 14:22:21 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-03-26 14:22:21 -0400 |
commit | 501a84985899a55e8e4fb8be71f2200c14dbae96 (patch) | |
tree | d313fd13fea6f0241aeaf0d96f7b2b07fc9699b2 /Command | |
parent | 57f324d802ef82920a1ed37875606f02a5f31f95 (diff) |
git-annex-shell: Make configlist automatically initialize a remote git repository, as long as a git-annex branch has been pushed to it, to simplify setup of remote git repositories, including via gitolite.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/ConfigList.hs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/Command/ConfigList.hs b/Command/ConfigList.hs index 58b738864..219685c21 100644 --- a/Command/ConfigList.hs +++ b/Command/ConfigList.hs @@ -1,6 +1,6 @@ {- git-annex command - - - Copyright 2010 Joey Hess <joey@kitenet.net> + - Copyright 2010-2014 Joey Hess <joey@kitenet.net> - - Licensed under the GNU GPL version 3 or higher. -} @@ -10,6 +10,8 @@ module Command.ConfigList where import Common.Annex import Command import Annex.UUID +import Annex.Init +import qualified Annex.Branch import qualified Git.Config import Remote.GCrypt (coreGCryptId) @@ -22,9 +24,23 @@ seek = withNothing start start :: CommandStart start = do - u <- getUUID + u <- findOrGenUUID showConfig "annex.uuid" $ fromUUID u showConfig coreGCryptId =<< fromRepo (Git.Config.get coreGCryptId "") stop where showConfig k v = liftIO $ putStrLn $ k ++ "=" ++ v + +{- The repository may not yet have a UUID; automatically initialize it + - when there's a git-annex branch available. -} +findOrGenUUID :: Annex UUID +findOrGenUUID = do + u <- getUUID + if u /= NoUUID + then return u + else ifM Annex.Branch.hasSibling + ( do + initialize Nothing + getUUID + , return NoUUID + ) |