2010-12-30 20:08:22 -04:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2015-01-21 12:50:09 -04:00
|
|
|
- Copyright 2010-2014 Joey Hess <id@joeyh.name>
|
2010-12-30 20:08:22 -04:00
|
|
|
-
|
2019-03-13 15:48:14 -04:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2010-12-30 20:08:22 -04:00
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.ConfigList where
|
|
|
|
|
|
|
|
import Command
|
2011-10-15 17:47:03 -04:00
|
|
|
import Annex.UUID
|
2014-03-26 14:22:21 -04:00
|
|
|
import Annex.Init
|
|
|
|
import qualified Annex.Branch
|
2013-09-24 17:25:47 -04:00
|
|
|
import qualified Git.Config
|
2019-12-02 10:57:09 -04:00
|
|
|
import Git.Types
|
2013-09-24 17:25:47 -04:00
|
|
|
import Remote.GCrypt (coreGCryptId)
|
2015-08-05 13:49:54 -04:00
|
|
|
import qualified CmdLine.GitAnnexShell.Fields as Fields
|
2015-08-05 14:09:25 -04:00
|
|
|
import CmdLine.GitAnnexShell.Checks
|
2010-12-30 20:08:22 -04:00
|
|
|
|
2015-07-08 12:33:27 -04:00
|
|
|
cmd :: Command
|
2015-08-05 13:49:54 -04:00
|
|
|
cmd = noCommit $ dontCheck repoExists $
|
2015-07-08 15:08:02 -04:00
|
|
|
command "configlist" SectionPlumbing
|
|
|
|
"outputs relevant git configuration"
|
|
|
|
paramNothing (withParams seek)
|
2010-12-30 20:08:22 -04:00
|
|
|
|
2015-07-08 12:33:27 -04:00
|
|
|
seek :: CmdParams -> CommandSeek
|
2018-10-01 14:12:06 -04:00
|
|
|
seek = withNothing (commandAction start)
|
2010-12-30 20:08:22 -04:00
|
|
|
|
2011-09-15 16:50:49 -04:00
|
|
|
start :: CommandStart
|
2010-12-30 20:08:22 -04:00
|
|
|
start = do
|
2014-03-26 14:22:21 -04:00
|
|
|
u <- findOrGenUUID
|
2019-12-02 10:57:09 -04:00
|
|
|
showConfig configkeyUUID $ fromUUID u
|
2019-12-05 14:36:43 -04:00
|
|
|
showConfig coreGCryptId . fromConfigValue
|
2019-12-02 10:57:09 -04:00
|
|
|
=<< fromRepo (Git.Config.get coreGCryptId mempty)
|
2011-05-15 02:02:46 -04:00
|
|
|
stop
|
2013-09-24 17:25:47 -04:00
|
|
|
where
|
2019-12-02 10:57:09 -04:00
|
|
|
showConfig k v = liftIO $ putStrLn $ fromConfigKey k ++ "=" ++ v
|
2014-03-26 14:22:21 -04:00
|
|
|
|
|
|
|
{- The repository may not yet have a UUID; automatically initialize it
|
2015-08-05 13:49:54 -04:00
|
|
|
- when there's a git-annex branch available or if the autoinit field was
|
|
|
|
- set. -}
|
2014-03-26 14:22:21 -04:00
|
|
|
findOrGenUUID :: Annex UUID
|
|
|
|
findOrGenUUID = do
|
|
|
|
u <- getUUID
|
|
|
|
if u /= NoUUID
|
|
|
|
then return u
|
2015-08-05 13:49:54 -04:00
|
|
|
else ifM (Annex.Branch.hasSibling <||> (isJust <$> Fields.getField Fields.autoInit))
|
2014-03-26 14:22:21 -04:00
|
|
|
( do
|
2015-08-05 14:09:25 -04:00
|
|
|
liftIO checkNotReadOnly
|
2022-11-18 13:58:35 -04:00
|
|
|
initialize Nothing Nothing
|
2014-03-26 14:22:21 -04:00
|
|
|
getUUID
|
|
|
|
, return NoUUID
|
|
|
|
)
|