Merge branch 'master' into s3-aws
Conflicts: Remote/S3.hs
This commit is contained in:
commit
35551d0ed0
502 changed files with 7127 additions and 2453 deletions
|
@ -19,6 +19,7 @@ import Types.TrustLevel
|
|||
import Types.UUID
|
||||
|
||||
import qualified Data.Map as M
|
||||
import Data.Default
|
||||
|
||||
data FileTransition
|
||||
= ChangeFile String
|
||||
|
@ -60,4 +61,4 @@ dropDeadFromPresenceLog :: TrustMap -> [Presence.LogLine] -> [Presence.LogLine]
|
|||
dropDeadFromPresenceLog trustmap = filter $ notDead trustmap (toUUID . Presence.info)
|
||||
|
||||
notDead :: TrustMap -> (v -> UUID) -> v -> Bool
|
||||
notDead trustmap a v = M.findWithDefault SemiTrusted (a v) trustmap /= DeadTrusted
|
||||
notDead trustmap a v = M.findWithDefault def (a v) trustmap /= DeadTrusted
|
||||
|
|
|
@ -13,10 +13,7 @@ import Common.Annex
|
|||
import Utility.UserInfo
|
||||
import qualified Git.Config
|
||||
import Config
|
||||
|
||||
#ifndef mingw32_HOST_OS
|
||||
import Utility.Env
|
||||
#endif
|
||||
|
||||
{- Checks that the system's environment allows git to function.
|
||||
- Git requires a GECOS username, or suitable git configuration, or
|
||||
|
@ -35,24 +32,19 @@ checkEnvironment = do
|
|||
liftIO checkEnvironmentIO
|
||||
|
||||
checkEnvironmentIO :: IO ()
|
||||
checkEnvironmentIO =
|
||||
#ifdef mingw32_HOST_OS
|
||||
noop
|
||||
#else
|
||||
whenM (null <$> myUserGecos) $ do
|
||||
checkEnvironmentIO = whenM (null <$> myUserGecos) $ do
|
||||
username <- myUserName
|
||||
ensureEnv "GIT_AUTHOR_NAME" username
|
||||
ensureEnv "GIT_COMMITTER_NAME" username
|
||||
where
|
||||
#ifndef __ANDROID__
|
||||
-- existing environment is not overwritten
|
||||
ensureEnv var val = void $ setEnv var val False
|
||||
ensureEnv var val = setEnv var val False
|
||||
#else
|
||||
-- Environment setting is broken on Android, so this is dealt with
|
||||
-- in runshell instead.
|
||||
ensureEnv _ _ = noop
|
||||
#endif
|
||||
#endif
|
||||
|
||||
{- Runs an action that commits to the repository, and if it fails,
|
||||
- sets user.email and user.name to a dummy value and tries the action again. -}
|
||||
|
|
30
Assistant.hs
30
Assistant.hs
|
@ -147,7 +147,7 @@ startDaemon assistant foreground startdelay cannotrun listenhost startbrowser =
|
|||
let threads = if isJust cannotrun
|
||||
then webappthread
|
||||
else webappthread ++
|
||||
[ watch $ commitThread
|
||||
[ watch commitThread
|
||||
#ifdef WITH_WEBAPP
|
||||
#ifdef WITH_PAIRING
|
||||
, assist $ pairListenerThread urlrenderer
|
||||
|
@ -158,29 +158,29 @@ startDaemon assistant foreground startdelay cannotrun listenhost startbrowser =
|
|||
, assist $ xmppReceivePackThread urlrenderer
|
||||
#endif
|
||||
#endif
|
||||
, assist $ pushThread
|
||||
, assist $ pushRetryThread
|
||||
, assist $ mergeThread
|
||||
, assist $ transferWatcherThread
|
||||
, assist $ transferPollerThread
|
||||
, assist $ transfererThread
|
||||
, assist $ remoteControlThread
|
||||
, assist $ daemonStatusThread
|
||||
, assist pushThread
|
||||
, assist pushRetryThread
|
||||
, assist mergeThread
|
||||
, assist transferWatcherThread
|
||||
, assist transferPollerThread
|
||||
, assist transfererThread
|
||||
, assist remoteControlThread
|
||||
, assist daemonStatusThread
|
||||
, assist $ sanityCheckerDailyThread urlrenderer
|
||||
, assist $ sanityCheckerHourlyThread
|
||||
, assist sanityCheckerHourlyThread
|
||||
, assist $ problemFixerThread urlrenderer
|
||||
#ifdef WITH_CLIBS
|
||||
, assist $ mountWatcherThread urlrenderer
|
||||
#endif
|
||||
, assist $ netWatcherThread
|
||||
, assist netWatcherThread
|
||||
, assist $ upgraderThread urlrenderer
|
||||
, assist $ upgradeWatcherThread urlrenderer
|
||||
, assist $ netWatcherFallbackThread
|
||||
, assist netWatcherFallbackThread
|
||||
, assist $ transferScannerThread urlrenderer
|
||||
, assist $ cronnerThread urlrenderer
|
||||
, assist $ configMonitorThread
|
||||
, assist $ glacierThread
|
||||
, watch $ watchThread
|
||||
, assist configMonitorThread
|
||||
, assist glacierThread
|
||||
, watch watchThread
|
||||
-- must come last so that all threads that wait
|
||||
-- on it have already started waiting
|
||||
, watch $ sanityCheckerStartupThread startdelay
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
-}
|
||||
|
||||
{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE ViewPatterns, OverloadedStrings #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ unattendedUpgrade = do
|
|||
prepUpgrade :: Assistant ()
|
||||
prepUpgrade = do
|
||||
void $ addAlert upgradingAlert
|
||||
void $ liftIO $ setEnv upgradedEnv "1" True
|
||||
liftIO $ setEnv upgradedEnv "1" True
|
||||
prepRestart
|
||||
|
||||
postUpgrade :: URLString -> Assistant ()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
-- | Helper functions for creating forms when using Bootstrap v3.
|
||||
-- This is a copy of the Yesod.Form.Bootstrap3 module that has been slightly
|
||||
-- modified to be compatible with Yesod 1.0.1
|
||||
|
@ -149,20 +148,13 @@ data BootstrapFormLayout =
|
|||
-- > ^{bootstrapSubmit MsgSubmit}
|
||||
--
|
||||
-- Since: yesod-form 1.3.8
|
||||
#if MIN_VERSION_yesod(1,2,0)
|
||||
renderBootstrap3 :: Monad m => BootstrapFormLayout -> FormRender m a
|
||||
#else
|
||||
renderBootstrap3 :: BootstrapFormLayout -> FormRender sub master a
|
||||
#endif
|
||||
renderBootstrap3 formLayout aform fragment = do
|
||||
(res, views') <- aFormToForm aform
|
||||
let views = views' []
|
||||
has (Just _) = True
|
||||
has Nothing = False
|
||||
widget = [whamlet|
|
||||
#if MIN_VERSION_yesod(1,2,0)
|
||||
$newline never
|
||||
#endif
|
||||
#{fragment}
|
||||
$forall view <- views
|
||||
<div .form-group :fvRequired view:.required :not $ fvRequired view:.optional :has $ fvErrors view:.has-error>
|
||||
|
@ -193,11 +185,7 @@ renderBootstrap3 formLayout aform fragment = do
|
|||
nequals a b = a /= b -- work around older hamlet versions not liking /=
|
||||
|
||||
-- | (Internal) Render a help widget for tooltips and errors.
|
||||
#if MIN_VERSION_yesod(1,2,0)
|
||||
helpWidget :: FieldView site -> WidgetT site IO ()
|
||||
#else
|
||||
helpWidget :: FieldView sub master -> GWidget sub master ()
|
||||
#endif
|
||||
helpWidget view = [whamlet|
|
||||
$maybe tt <- fvTooltip view
|
||||
<span .help-block>#{tt}
|
||||
|
@ -242,13 +230,7 @@ instance IsString msg => IsString (BootstrapSubmit msg) where
|
|||
-- layout.
|
||||
--
|
||||
-- Since: yesod-form 1.3.8
|
||||
#if MIN_VERSION_yesod(1,2,0)
|
||||
bootstrapSubmit
|
||||
:: (RenderMessage site msg, HandlerSite m ~ site, MonadHandler m)
|
||||
=> BootstrapSubmit msg -> AForm m ()
|
||||
#else
|
||||
bootstrapSubmit :: (RenderMessage master msg) => BootstrapSubmit msg -> AForm sub master ()
|
||||
#endif
|
||||
bootstrapSubmit = formToAForm . liftM (second return) . mbootstrapSubmit
|
||||
|
||||
|
||||
|
@ -257,13 +239,7 @@ bootstrapSubmit = formToAForm . liftM (second return) . mbootstrapSubmit
|
|||
-- anyway.
|
||||
--
|
||||
-- Since: yesod-form 1.3.8
|
||||
#if MIN_VERSION_yesod(1,2,0)
|
||||
mbootstrapSubmit
|
||||
:: (RenderMessage site msg, HandlerSite m ~ site, MonadHandler m)
|
||||
=> BootstrapSubmit msg -> MForm m (FormResult (), FieldView site)
|
||||
#else
|
||||
mbootstrapSubmit :: (RenderMessage master msg) => BootstrapSubmit msg -> MForm sub master (FormResult (), FieldView sub master)
|
||||
#endif
|
||||
mbootstrapSubmit (BootstrapSubmit msg classes attrs) =
|
||||
let res = FormSuccess ()
|
||||
widget = [whamlet|<button class="btn #{classes}" type=submit *{attrs}>_{msg}|]
|
||||
|
|
|
@ -162,7 +162,7 @@ getEnableS3R :: UUID -> Handler Html
|
|||
#ifdef WITH_S3
|
||||
getEnableS3R uuid = do
|
||||
m <- liftAnnex readRemoteLog
|
||||
if isIARemoteConfig $ fromJust $ M.lookup uuid m
|
||||
if maybe False S3.isIA (M.lookup uuid m)
|
||||
then redirect $ EnableIAR uuid
|
||||
else postEnableS3R uuid
|
||||
#else
|
||||
|
@ -220,12 +220,9 @@ getRepoInfo c = [whamlet|S3 remote using bucket: #{bucket}|]
|
|||
bucket = fromMaybe "" $ M.lookup "bucket" c
|
||||
|
||||
#ifdef WITH_S3
|
||||
isIARemoteConfig :: RemoteConfig -> Bool
|
||||
isIARemoteConfig = S3.isIAHost . fromMaybe "" . M.lookup "host"
|
||||
|
||||
previouslyUsedAWSCreds :: Annex (Maybe CredPair)
|
||||
previouslyUsedAWSCreds = getM gettype [S3.remote, Glacier.remote]
|
||||
where
|
||||
gettype t = previouslyUsedCredPair AWS.creds t $
|
||||
not . isIARemoteConfig . Remote.config
|
||||
not . S3.isIA . Remote.config
|
||||
#endif
|
||||
|
|
|
@ -107,7 +107,7 @@ iaCredsAForm defcreds = AWS.AWSCreds
|
|||
#ifdef WITH_S3
|
||||
previouslyUsedIACreds :: Annex (Maybe CredPair)
|
||||
previouslyUsedIACreds = previouslyUsedCredPair AWS.creds S3.remote $
|
||||
AWS.isIARemoteConfig . Remote.config
|
||||
S3.isIA . Remote.config
|
||||
#endif
|
||||
|
||||
accessKeyIDFieldWithHelp :: Maybe Text -> MkAForm Text
|
||||
|
|
|
@ -25,8 +25,12 @@ import Data.String (IsString (..))
|
|||
import Control.Monad (unless)
|
||||
import Data.Maybe (listToMaybe)
|
||||
#endif
|
||||
#if MIN_VERSION_yesod_form(1,3,8)
|
||||
import Yesod.Form.Bootstrap3 as Y hiding (bfs)
|
||||
#else
|
||||
import Assistant.WebApp.Bootstrap3 as Y hiding (bfs)
|
||||
#endif
|
||||
import Data.Text (Text)
|
||||
import Assistant.WebApp.Bootstrap3 hiding (bfs)
|
||||
|
||||
{- Yesod's textField sets the required attribute for required fields.
|
||||
- We don't want this, because many of the forms used in this webapp
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE TemplateHaskell, OverloadedStrings, RankNTypes #-}
|
||||
{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances, FlexibleContexts, ViewPatterns #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
-}
|
||||
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
|
||||
module CmdLine (
|
||||
dispatch,
|
||||
|
|
|
@ -107,91 +107,91 @@ import System.Remote.Monitoring
|
|||
|
||||
cmds :: [Command]
|
||||
cmds = concat
|
||||
[ Command.Add.def
|
||||
, Command.Get.def
|
||||
, Command.Drop.def
|
||||
, Command.Move.def
|
||||
, Command.Copy.def
|
||||
, Command.Unlock.def
|
||||
, Command.Lock.def
|
||||
, Command.Sync.def
|
||||
, Command.Mirror.def
|
||||
, Command.AddUrl.def
|
||||
[ Command.Add.cmd
|
||||
, Command.Get.cmd
|
||||
, Command.Drop.cmd
|
||||
, Command.Move.cmd
|
||||
, Command.Copy.cmd
|
||||
, Command.Unlock.cmd
|
||||
, Command.Lock.cmd
|
||||
, Command.Sync.cmd
|
||||
, Command.Mirror.cmd
|
||||
, Command.AddUrl.cmd
|
||||
#ifdef WITH_FEED
|
||||
, Command.ImportFeed.def
|
||||
, Command.ImportFeed.cmd
|
||||
#endif
|
||||
, Command.RmUrl.def
|
||||
, Command.Import.def
|
||||
, Command.Init.def
|
||||
, Command.Describe.def
|
||||
, Command.InitRemote.def
|
||||
, Command.EnableRemote.def
|
||||
, Command.Reinject.def
|
||||
, Command.Unannex.def
|
||||
, Command.Uninit.def
|
||||
, Command.Reinit.def
|
||||
, Command.PreCommit.def
|
||||
, Command.NumCopies.def
|
||||
, Command.Trust.def
|
||||
, Command.Untrust.def
|
||||
, Command.Semitrust.def
|
||||
, Command.Dead.def
|
||||
, Command.Group.def
|
||||
, Command.Wanted.def
|
||||
, Command.Schedule.def
|
||||
, Command.Ungroup.def
|
||||
, Command.Vicfg.def
|
||||
, Command.LookupKey.def
|
||||
, Command.ExamineKey.def
|
||||
, Command.FromKey.def
|
||||
, Command.DropKey.def
|
||||
, Command.TransferKey.def
|
||||
, Command.TransferKeys.def
|
||||
, Command.ReKey.def
|
||||
, Command.MetaData.def
|
||||
, Command.View.def
|
||||
, Command.VAdd.def
|
||||
, Command.VFilter.def
|
||||
, Command.VPop.def
|
||||
, Command.VCycle.def
|
||||
, Command.Fix.def
|
||||
, Command.Fsck.def
|
||||
, Command.Repair.def
|
||||
, Command.Unused.def
|
||||
, Command.DropUnused.def
|
||||
, Command.AddUnused.def
|
||||
, Command.Find.def
|
||||
, Command.FindRef.def
|
||||
, Command.Whereis.def
|
||||
, Command.List.def
|
||||
, Command.Log.def
|
||||
, Command.Merge.def
|
||||
, Command.ResolveMerge.def
|
||||
, Command.Info.def
|
||||
, Command.Status.def
|
||||
, Command.Migrate.def
|
||||
, Command.Map.def
|
||||
, Command.Direct.def
|
||||
, Command.Indirect.def
|
||||
, Command.Upgrade.def
|
||||
, Command.Forget.def
|
||||
, Command.Version.def
|
||||
, Command.Help.def
|
||||
, Command.RmUrl.cmd
|
||||
, Command.Import.cmd
|
||||
, Command.Init.cmd
|
||||
, Command.Describe.cmd
|
||||
, Command.InitRemote.cmd
|
||||
, Command.EnableRemote.cmd
|
||||
, Command.Reinject.cmd
|
||||
, Command.Unannex.cmd
|
||||
, Command.Uninit.cmd
|
||||
, Command.Reinit.cmd
|
||||
, Command.PreCommit.cmd
|
||||
, Command.NumCopies.cmd
|
||||
, Command.Trust.cmd
|
||||
, Command.Untrust.cmd
|
||||
, Command.Semitrust.cmd
|
||||
, Command.Dead.cmd
|
||||
, Command.Group.cmd
|
||||
, Command.Wanted.cmd
|
||||
, Command.Schedule.cmd
|
||||
, Command.Ungroup.cmd
|
||||
, Command.Vicfg.cmd
|
||||
, Command.LookupKey.cmd
|
||||
, Command.ExamineKey.cmd
|
||||
, Command.FromKey.cmd
|
||||
, Command.DropKey.cmd
|
||||
, Command.TransferKey.cmd
|
||||
, Command.TransferKeys.cmd
|
||||
, Command.ReKey.cmd
|
||||
, Command.MetaData.cmd
|
||||
, Command.View.cmd
|
||||
, Command.VAdd.cmd
|
||||
, Command.VFilter.cmd
|
||||
, Command.VPop.cmd
|
||||
, Command.VCycle.cmd
|
||||
, Command.Fix.cmd
|
||||
, Command.Fsck.cmd
|
||||
, Command.Repair.cmd
|
||||
, Command.Unused.cmd
|
||||
, Command.DropUnused.cmd
|
||||
, Command.AddUnused.cmd
|
||||
, Command.Find.cmd
|
||||
, Command.FindRef.cmd
|
||||
, Command.Whereis.cmd
|
||||
, Command.List.cmd
|
||||
, Command.Log.cmd
|
||||
, Command.Merge.cmd
|
||||
, Command.ResolveMerge.cmd
|
||||
, Command.Info.cmd
|
||||
, Command.Status.cmd
|
||||
, Command.Migrate.cmd
|
||||
, Command.Map.cmd
|
||||
, Command.Direct.cmd
|
||||
, Command.Indirect.cmd
|
||||
, Command.Upgrade.cmd
|
||||
, Command.Forget.cmd
|
||||
, Command.Version.cmd
|
||||
, Command.Help.cmd
|
||||
#ifdef WITH_ASSISTANT
|
||||
, Command.Watch.def
|
||||
, Command.Assistant.def
|
||||
, Command.Watch.cmd
|
||||
, Command.Assistant.cmd
|
||||
#ifdef WITH_WEBAPP
|
||||
, Command.WebApp.def
|
||||
, Command.WebApp.cmd
|
||||
#endif
|
||||
#ifdef WITH_XMPP
|
||||
, Command.XMPPGit.def
|
||||
, Command.XMPPGit.cmd
|
||||
#endif
|
||||
, Command.RemoteDaemon.def
|
||||
, Command.RemoteDaemon.cmd
|
||||
#endif
|
||||
, Command.Test.def
|
||||
, Command.Test.cmd
|
||||
#ifdef WITH_TESTSUITE
|
||||
, Command.FuzzTest.def
|
||||
, Command.TestRemote.def
|
||||
, Command.FuzzTest.cmd
|
||||
, Command.TestRemote.cmd
|
||||
#endif
|
||||
]
|
||||
|
||||
|
|
|
@ -34,19 +34,19 @@ import qualified Command.GCryptSetup
|
|||
|
||||
cmds_readonly :: [Command]
|
||||
cmds_readonly = concat
|
||||
[ gitAnnexShellCheck Command.ConfigList.def
|
||||
, gitAnnexShellCheck Command.InAnnex.def
|
||||
, gitAnnexShellCheck Command.SendKey.def
|
||||
, gitAnnexShellCheck Command.TransferInfo.def
|
||||
, gitAnnexShellCheck Command.NotifyChanges.def
|
||||
[ gitAnnexShellCheck Command.ConfigList.cmd
|
||||
, gitAnnexShellCheck Command.InAnnex.cmd
|
||||
, gitAnnexShellCheck Command.SendKey.cmd
|
||||
, gitAnnexShellCheck Command.TransferInfo.cmd
|
||||
, gitAnnexShellCheck Command.NotifyChanges.cmd
|
||||
]
|
||||
|
||||
cmds_notreadonly :: [Command]
|
||||
cmds_notreadonly = concat
|
||||
[ gitAnnexShellCheck Command.RecvKey.def
|
||||
, gitAnnexShellCheck Command.DropKey.def
|
||||
, gitAnnexShellCheck Command.Commit.def
|
||||
, Command.GCryptSetup.def
|
||||
[ gitAnnexShellCheck Command.RecvKey.cmd
|
||||
, gitAnnexShellCheck Command.DropKey.cmd
|
||||
, gitAnnexShellCheck Command.Commit.cmd
|
||||
, Command.GCryptSetup.cmd
|
||||
]
|
||||
|
||||
cmds :: [Command]
|
||||
|
|
|
@ -103,6 +103,8 @@ paramSize :: String
|
|||
paramSize = "SIZE"
|
||||
paramAddress :: String
|
||||
paramAddress = "ADDRESS"
|
||||
paramItem :: String
|
||||
paramItem = "ITEM"
|
||||
paramKeyValue :: String
|
||||
paramKeyValue = "K=V"
|
||||
paramNothing :: String
|
||||
|
|
|
@ -34,8 +34,8 @@ import Utility.Tmp
|
|||
|
||||
import Control.Exception (IOException)
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ withOptions [includeDotFilesOption] $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ withOptions [includeDotFilesOption] $
|
||||
command "add" paramPaths seek SectionCommon
|
||||
"add files to annex"]
|
||||
|
||||
|
@ -177,14 +177,14 @@ ingest (Just source) = withTSDelta $ \delta -> do
|
|||
(undo (keyFilename source) key)
|
||||
maybe noop (genMetaData key (keyFilename source)) ms
|
||||
liftIO $ nukeFile $ keyFilename source
|
||||
return $ (Just key, mcache)
|
||||
return (Just key, mcache)
|
||||
goindirect _ _ _ = failure "failed to generate a key"
|
||||
|
||||
godirect (Just (key, _)) (Just cache) ms = do
|
||||
addInodeCache key cache
|
||||
maybe noop (genMetaData key (keyFilename source)) ms
|
||||
finishIngestDirect key source
|
||||
return $ (Just key, Just cache)
|
||||
return (Just key, Just cache)
|
||||
godirect _ _ _ = failure "failed to generate a key"
|
||||
|
||||
failure msg = do
|
||||
|
|
|
@ -14,8 +14,8 @@ import qualified Command.Add
|
|||
import Command.Unused (withUnusedMaps, UnusedMaps(..), startUnused)
|
||||
import Types.Key
|
||||
|
||||
def :: [Command]
|
||||
def = [notDirect $ command "addunused" (paramRepeating paramNumRange)
|
||||
cmd :: [Command]
|
||||
cmd = [notDirect $ command "addunused" (paramRepeating paramNumRange)
|
||||
seek SectionMaintenance "add back unused files"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -32,8 +32,8 @@ import Annex.Quvi
|
|||
import qualified Utility.Quvi as Quvi
|
||||
#endif
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ withOptions [fileOption, pathdepthOption, relaxedOption] $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ withOptions [fileOption, pathdepthOption, relaxedOption] $
|
||||
command "addurl" (paramRepeating paramUrl) seek
|
||||
SectionCommon "add urls to annex"]
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import Assistant.Install
|
|||
|
||||
import System.Environment
|
||||
|
||||
def :: [Command]
|
||||
def = [noRepo checkAutoStart $ dontCheck repoExists $ withOptions options $
|
||||
cmd :: [Command]
|
||||
cmd = [noRepo checkAutoStart $ dontCheck repoExists $ withOptions options $
|
||||
notBareRepo $ command "assistant" paramNothing seek SectionCommon
|
||||
"automatically handle changes"]
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ import Command
|
|||
import qualified Annex.Branch
|
||||
import qualified Git
|
||||
|
||||
def :: [Command]
|
||||
def = [command "commit" paramNothing seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "commit" paramNothing seek
|
||||
SectionPlumbing "commits any staged changes to the git-annex branch"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -15,8 +15,8 @@ import qualified Annex.Branch
|
|||
import qualified Git.Config
|
||||
import Remote.GCrypt (coreGCryptId)
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ command "configlist" paramNothing seek
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ command "configlist" paramNothing seek
|
||||
SectionPlumbing "outputs relevant git configuration"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -14,8 +14,8 @@ import qualified Remote
|
|||
import Annex.Wanted
|
||||
import Config.NumCopies
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions Command.Move.moveOptions $ command "copy" paramPaths seek
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions Command.Move.moveOptions $ command "copy" paramPaths seek
|
||||
SectionCommon "copy content of files to/from another repository"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -11,8 +11,8 @@ import Command
|
|||
import Types.TrustLevel
|
||||
import Command.Trust (trustCommand)
|
||||
|
||||
def :: [Command]
|
||||
def = [command "dead" (paramRepeating paramRemote) seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "dead" (paramRepeating paramRemote) seek
|
||||
SectionSetup "hide a lost repository"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -12,8 +12,8 @@ import Command
|
|||
import qualified Remote
|
||||
import Logs.UUID
|
||||
|
||||
def :: [Command]
|
||||
def = [command "describe" (paramPair paramRemote paramDesc) seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "describe" (paramPair paramRemote paramDesc) seek
|
||||
SectionSetup "change description of a repository"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -15,8 +15,8 @@ import qualified Git.Branch
|
|||
import Config
|
||||
import Annex.Direct
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ noDaemonRunning $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ noDaemonRunning $
|
||||
command "direct" paramNothing seek
|
||||
SectionSetup "switch repository to direct mode"]
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import Annex.Notification
|
|||
|
||||
import qualified Data.Set as S
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions [dropFromOption] $ command "drop" paramPaths seek
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions [dropFromOption] $ command "drop" paramPaths seek
|
||||
SectionCommon "indicate content of files not currently wanted"]
|
||||
|
||||
dropFromOption :: Option
|
||||
|
|
|
@ -13,8 +13,8 @@ import qualified Annex
|
|||
import Logs.Location
|
||||
import Annex.Content
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ command "dropkey" (paramRepeating paramKey) seek
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ command "dropkey" (paramRepeating paramKey) seek
|
||||
SectionPlumbing "drops annexed content for specified keys"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -16,8 +16,8 @@ import qualified Git
|
|||
import Command.Unused (withUnusedMaps, UnusedMaps(..), startUnused)
|
||||
import Config.NumCopies
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions [Command.Drop.dropFromOption] $
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions [Command.Drop.dropFromOption] $
|
||||
command "dropunused" (paramRepeating paramNumRange)
|
||||
seek SectionMaintenance "drop unused file content"]
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ import qualified Command.InitRemote as InitRemote
|
|||
|
||||
import qualified Data.Map as M
|
||||
|
||||
def :: [Command]
|
||||
def = [command "enableremote"
|
||||
cmd :: [Command]
|
||||
cmd = [command "enableremote"
|
||||
(paramPair paramName $ paramOptional $ paramRepeating paramKeyValue)
|
||||
seek SectionSetup "enables use of an existing special remote"]
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import qualified Utility.Format
|
|||
import Command.Find (formatOption, getFormat, showFormatted, keyVars)
|
||||
import Types.Key
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ noMessages $ withOptions [formatOption, jsonOption] $
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ noMessages $ withOptions [formatOption, jsonOption] $
|
||||
command "examinekey" (paramRepeating paramKey) seek
|
||||
SectionPlumbing "prints information from a key"]
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import qualified Utility.Format
|
|||
import Utility.DataUnits
|
||||
import Types.Key
|
||||
|
||||
def :: [Command]
|
||||
def = [mkCommand $ command "find" paramPaths seek SectionQuery "lists available files"]
|
||||
cmd :: [Command]
|
||||
cmd = [mkCommand $ command "find" paramPaths seek SectionQuery "lists available files"]
|
||||
|
||||
mkCommand :: Command -> Command
|
||||
mkCommand = noCommit . noMessages . withOptions [formatOption, print0Option, jsonOption]
|
||||
|
|
|
@ -10,8 +10,8 @@ module Command.FindRef where
|
|||
import Command
|
||||
import qualified Command.Find as Find
|
||||
|
||||
def :: [Command]
|
||||
def = [Find.mkCommand $ command "findref" paramRef seek SectionPlumbing
|
||||
cmd :: [Command]
|
||||
cmd = [Find.mkCommand $ command "findref" paramRef seek SectionPlumbing
|
||||
"lists files in a git ref"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -18,8 +18,8 @@ import Utility.Touch
|
|||
#endif
|
||||
#endif
|
||||
|
||||
def :: [Command]
|
||||
def = [notDirect $ noCommit $ command "fix" paramPaths seek
|
||||
cmd :: [Command]
|
||||
cmd = [notDirect $ noCommit $ command "fix" paramPaths seek
|
||||
SectionMaintenance "fix up symlinks to point to annexed content"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -15,8 +15,8 @@ import qualified Annex
|
|||
|
||||
import Data.Time.Clock.POSIX
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions forgetOptions $ command "forget" paramNothing seek
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions forgetOptions $ command "forget" paramNothing seek
|
||||
SectionMaintenance "prune git-annex branch history"]
|
||||
|
||||
forgetOptions :: [Option]
|
||||
|
|
|
@ -13,8 +13,8 @@ import qualified Annex.Queue
|
|||
import Annex.Content
|
||||
import Types.Key
|
||||
|
||||
def :: [Command]
|
||||
def = [notDirect $ notBareRepo $
|
||||
cmd :: [Command]
|
||||
cmd = [notDirect $ notBareRepo $
|
||||
command "fromkey" (paramPair paramKey paramPath) seek
|
||||
SectionPlumbing "adds a file using a specific key"]
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ import Data.Time
|
|||
import System.Posix.Types (EpochTime)
|
||||
import System.Locale
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions fsckOptions $ command "fsck" paramPaths seek
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions fsckOptions $ command "fsck" paramPaths seek
|
||||
SectionMaintenance "check for problems"]
|
||||
|
||||
fsckFromOption :: Option
|
||||
|
|
|
@ -20,8 +20,8 @@ import System.Random (getStdRandom, random, randomR)
|
|||
import Test.QuickCheck
|
||||
import Control.Concurrent
|
||||
|
||||
def :: [Command]
|
||||
def = [ notBareRepo $ command "fuzztest" paramNothing seek SectionTesting
|
||||
cmd :: [Command]
|
||||
cmd = [ notBareRepo $ command "fuzztest" paramNothing seek SectionTesting
|
||||
"generates fuzz test files"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -13,8 +13,8 @@ import Annex.UUID
|
|||
import qualified Remote.GCrypt
|
||||
import qualified Git
|
||||
|
||||
def :: [Command]
|
||||
def = [dontCheck repoExists $ noCommit $
|
||||
cmd :: [Command]
|
||||
cmd = [dontCheck repoExists $ noCommit $
|
||||
command "gcryptsetup" paramValue seek
|
||||
SectionPlumbing "sets up gcrypt repository"]
|
||||
|
||||
|
@ -30,7 +30,7 @@ start gcryptid = next $ next $ do
|
|||
g <- gitRepo
|
||||
gu <- Remote.GCrypt.getGCryptUUID True g
|
||||
let newgu = genUUIDInNameSpace gCryptNameSpace gcryptid
|
||||
if gu == Nothing || gu == Just newgu
|
||||
if isNothing gu || gu == Just newgu
|
||||
then if Git.repoIsLocalBare g
|
||||
then do
|
||||
void $ Remote.GCrypt.setupRepo gcryptid g
|
||||
|
|
|
@ -16,8 +16,8 @@ import Config.NumCopies
|
|||
import Annex.Wanted
|
||||
import qualified Command.Move
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions getOptions $ command "get" paramPaths seek
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions getOptions $ command "get" paramPaths seek
|
||||
SectionCommon "make content of annexed files available"]
|
||||
|
||||
getOptions :: [Option]
|
||||
|
|
|
@ -15,8 +15,8 @@ import Types.Group
|
|||
|
||||
import qualified Data.Set as S
|
||||
|
||||
def :: [Command]
|
||||
def = [command "group" (paramPair paramRemote paramDesc) seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "group" (paramPair paramRemote paramDesc) seek
|
||||
SectionSetup "add a repository to a group"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -21,8 +21,8 @@ import qualified Command.Fsck
|
|||
|
||||
import System.Console.GetOpt
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
||||
command "help" paramNothing seek SectionQuery "display help"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
@ -47,15 +47,15 @@ showGeneralHelp :: IO ()
|
|||
showGeneralHelp = putStrLn $ unlines
|
||||
[ "The most frequently used git-annex commands are:"
|
||||
, unlines $ map cmdline $ concat
|
||||
[ Command.Init.def
|
||||
, Command.Add.def
|
||||
, Command.Drop.def
|
||||
, Command.Get.def
|
||||
, Command.Move.def
|
||||
, Command.Copy.def
|
||||
, Command.Sync.def
|
||||
, Command.Whereis.def
|
||||
, Command.Fsck.def
|
||||
[ Command.Init.cmd
|
||||
, Command.Add.cmd
|
||||
, Command.Drop.cmd
|
||||
, Command.Get.cmd
|
||||
, Command.Move.cmd
|
||||
, Command.Copy.cmd
|
||||
, Command.Sync.cmd
|
||||
, Command.Whereis.cmd
|
||||
, Command.Fsck.cmd
|
||||
]
|
||||
, "Run 'git-annex' for a complete command list."
|
||||
, "Run 'git-annex command --help' for help on a specific command."
|
||||
|
|
|
@ -16,8 +16,8 @@ import Backend
|
|||
import Remote
|
||||
import Types.KeySource
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions opts $ notBareRepo $ command "import" paramPaths seek
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions opts $ notBareRepo $ command "import" paramPaths seek
|
||||
SectionCommon "move and add files from outside git working copy"]
|
||||
|
||||
opts :: [Option]
|
||||
|
@ -96,7 +96,7 @@ start mode (srcfile, destfile) =
|
|||
handleexisting Nothing = noop
|
||||
handleexisting (Just s)
|
||||
| isDirectory s = notoverwriting "(is a directory)"
|
||||
| otherwise = ifM (Annex.getState Annex.force) $
|
||||
| otherwise = ifM (Annex.getState Annex.force)
|
||||
( liftIO $ nukeFile destfile
|
||||
, notoverwriting "(use --force to override)"
|
||||
)
|
||||
|
|
|
@ -37,8 +37,8 @@ import Types.MetaData
|
|||
import Logs.MetaData
|
||||
import Annex.MetaData
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ withOptions [templateOption, relaxedOption] $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ withOptions [templateOption, relaxedOption] $
|
||||
command "importfeed" (paramRepeating paramUrl) seek
|
||||
SectionCommon "import files from podcast feeds"]
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import Common.Annex
|
|||
import Command
|
||||
import Annex.Content
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ command "inannex" (paramRepeating paramKey) seek
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ command "inannex" (paramRepeating paramKey) seek
|
||||
SectionPlumbing "checks if keys are present in the annex"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -22,8 +22,8 @@ import Annex.CatFile
|
|||
import Annex.Init
|
||||
import qualified Command.Add
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ noDaemonRunning $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ noDaemonRunning $
|
||||
command "indirect" paramNothing seek
|
||||
SectionSetup "switch repository to indirect mode"]
|
||||
|
||||
|
|
139
Command/Info.hs
139
Command/Info.hs
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2011 Joey Hess <joey@kitenet.net>
|
||||
- Copyright 2011-2014 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -16,14 +16,16 @@ import Data.Tuple
|
|||
import Data.Ord
|
||||
|
||||
import Common.Annex
|
||||
import qualified Remote
|
||||
import qualified Command.Unused
|
||||
import qualified Git
|
||||
import qualified Annex
|
||||
import qualified Remote
|
||||
import qualified Types.Remote as Remote
|
||||
import Command
|
||||
import Utility.DataUnits
|
||||
import Utility.DiskFree
|
||||
import Annex.Content
|
||||
import Annex.Link
|
||||
import Types.Key
|
||||
import Logs.UUID
|
||||
import Logs.Trust
|
||||
|
@ -66,42 +68,67 @@ data StatInfo = StatInfo
|
|||
, numCopiesStats :: Maybe NumCopiesStats
|
||||
}
|
||||
|
||||
emptyStatInfo :: StatInfo
|
||||
emptyStatInfo = StatInfo Nothing Nothing Nothing
|
||||
|
||||
-- a state monad for running Stats in
|
||||
type StatState = StateT StatInfo Annex
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ dontCheck repoExists $ withOptions [jsonOption] $
|
||||
command "info" paramPaths seek SectionQuery
|
||||
"shows general information about the annex"]
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ dontCheck repoExists $ withOptions [jsonOption] $
|
||||
command "info" (paramOptional $ paramRepeating paramItem) seek SectionQuery
|
||||
"shows information about the specified item or the repository as a whole"]
|
||||
|
||||
seek :: CommandSeek
|
||||
seek = withWords start
|
||||
|
||||
start :: [FilePath] -> CommandStart
|
||||
start :: [String] -> CommandStart
|
||||
start [] = do
|
||||
globalInfo
|
||||
stop
|
||||
start ps = do
|
||||
mapM_ localInfo =<< filterM isdir ps
|
||||
mapM_ itemInfo ps
|
||||
stop
|
||||
where
|
||||
isdir = liftIO . catchBoolIO . (isDirectory <$$> getFileStatus)
|
||||
|
||||
globalInfo :: Annex ()
|
||||
globalInfo = do
|
||||
stats <- selStats global_fast_stats global_slow_stats
|
||||
showCustom "info" $ do
|
||||
evalStateT (mapM_ showStat stats) (StatInfo Nothing Nothing Nothing)
|
||||
evalStateT (mapM_ showStat stats) emptyStatInfo
|
||||
return True
|
||||
|
||||
localInfo :: FilePath -> Annex ()
|
||||
localInfo dir = showCustom (unwords ["info", dir]) $ do
|
||||
stats <- selStats (tostats local_fast_stats) (tostats local_slow_stats)
|
||||
evalStateT (mapM_ showStat stats) =<< getLocalStatInfo dir
|
||||
itemInfo :: String -> Annex ()
|
||||
itemInfo p = ifM (isdir p)
|
||||
( dirInfo p
|
||||
, do
|
||||
v <- Remote.byName' p
|
||||
case v of
|
||||
Right r -> remoteInfo r
|
||||
Left _ -> maybe noinfo (fileInfo p) =<< isAnnexLink p
|
||||
)
|
||||
where
|
||||
isdir = liftIO . catchBoolIO . (isDirectory <$$> getFileStatus)
|
||||
noinfo = error $ p ++ " is not a directory or an annexed file or a remote"
|
||||
|
||||
dirInfo :: FilePath -> Annex ()
|
||||
dirInfo dir = showCustom (unwords ["info", dir]) $ do
|
||||
stats <- selStats (tostats dir_fast_stats) (tostats dir_slow_stats)
|
||||
evalStateT (mapM_ showStat stats) =<< getDirStatInfo dir
|
||||
return True
|
||||
where
|
||||
tostats = map (\s -> s dir)
|
||||
|
||||
fileInfo :: FilePath -> Key -> Annex ()
|
||||
fileInfo file k = showCustom (unwords ["info", file]) $ do
|
||||
evalStateT (mapM_ showStat (file_stats file k)) emptyStatInfo
|
||||
return True
|
||||
|
||||
remoteInfo :: Remote -> Annex ()
|
||||
remoteInfo r = showCustom (unwords ["info", Remote.name r]) $ do
|
||||
info <- map (\(k, v) -> simpleStat k (pure v)) <$> Remote.getInfo r
|
||||
evalStateT (mapM_ showStat (remote_stats r ++ info)) emptyStatInfo
|
||||
return True
|
||||
|
||||
selStats :: [Stat] -> [Stat] -> Annex [Stat]
|
||||
selStats fast_stats slow_stats = do
|
||||
fast <- Annex.getState Annex.fast
|
||||
|
@ -132,22 +159,42 @@ global_slow_stats =
|
|||
, bloom_info
|
||||
, backend_usage
|
||||
]
|
||||
local_fast_stats :: [FilePath -> Stat]
|
||||
local_fast_stats =
|
||||
[ local_dir
|
||||
dir_fast_stats :: [FilePath -> Stat]
|
||||
dir_fast_stats =
|
||||
[ dir_name
|
||||
, const local_annex_keys
|
||||
, const local_annex_size
|
||||
, const known_annex_files
|
||||
, const known_annex_size
|
||||
]
|
||||
local_slow_stats :: [FilePath -> Stat]
|
||||
local_slow_stats =
|
||||
dir_slow_stats :: [FilePath -> Stat]
|
||||
dir_slow_stats =
|
||||
[ const numcopies_stats
|
||||
]
|
||||
|
||||
file_stats :: FilePath -> Key -> [Stat]
|
||||
file_stats f k =
|
||||
[ file_name f
|
||||
, key_size k
|
||||
, key_name k
|
||||
]
|
||||
|
||||
remote_stats :: Remote -> [Stat]
|
||||
remote_stats r = map (\s -> s r)
|
||||
[ remote_name
|
||||
, remote_description
|
||||
, remote_uuid
|
||||
, remote_cost
|
||||
, remote_type
|
||||
]
|
||||
|
||||
stat :: String -> (String -> StatState String) -> Stat
|
||||
stat desc a = return $ Just (desc, a desc)
|
||||
|
||||
-- The json simply contains the same string that is displayed.
|
||||
simpleStat :: String -> StatState String -> Stat
|
||||
simpleStat desc getval = stat desc $ json id getval
|
||||
|
||||
nostat :: Stat
|
||||
nostat = return Nothing
|
||||
|
||||
|
@ -168,7 +215,7 @@ showStat s = maybe noop calc =<< s
|
|||
lift . showRaw =<< a
|
||||
|
||||
repository_mode :: Stat
|
||||
repository_mode = stat "repository mode" $ json id $ lift $
|
||||
repository_mode = simpleStat "repository mode" $ lift $
|
||||
ifM isDirect
|
||||
( return "direct", return "indirect" )
|
||||
|
||||
|
@ -181,15 +228,37 @@ remote_list level = stat n $ nojson $ lift $ do
|
|||
where
|
||||
n = showTrustLevel level ++ " repositories"
|
||||
|
||||
local_dir :: FilePath -> Stat
|
||||
local_dir dir = stat "directory" $ json id $ return dir
|
||||
dir_name :: FilePath -> Stat
|
||||
dir_name dir = simpleStat "directory" $ pure dir
|
||||
|
||||
file_name :: FilePath -> Stat
|
||||
file_name file = simpleStat "file" $ pure file
|
||||
|
||||
remote_name :: Remote -> Stat
|
||||
remote_name r = simpleStat "remote" $ pure (Remote.name r)
|
||||
|
||||
remote_description :: Remote -> Stat
|
||||
remote_description r = simpleStat "description" $ lift $
|
||||
Remote.prettyUUID (Remote.uuid r)
|
||||
|
||||
remote_uuid :: Remote -> Stat
|
||||
remote_uuid r = simpleStat "uuid" $ pure $
|
||||
fromUUID $ Remote.uuid r
|
||||
|
||||
remote_cost :: Remote -> Stat
|
||||
remote_cost r = simpleStat "cost" $ pure $
|
||||
show $ Remote.cost r
|
||||
|
||||
remote_type :: Remote -> Stat
|
||||
remote_type r = simpleStat "type" $ pure $
|
||||
Remote.typename $ Remote.remotetype r
|
||||
|
||||
local_annex_keys :: Stat
|
||||
local_annex_keys = stat "local annex keys" $ json show $
|
||||
countKeys <$> cachedPresentData
|
||||
|
||||
local_annex_size :: Stat
|
||||
local_annex_size = stat "local annex size" $ json id $
|
||||
local_annex_size = simpleStat "local annex size" $
|
||||
showSizeKeys <$> cachedPresentData
|
||||
|
||||
known_annex_files :: Stat
|
||||
|
@ -197,7 +266,7 @@ known_annex_files = stat "annexed files in working tree" $ json show $
|
|||
countKeys <$> cachedReferencedData
|
||||
|
||||
known_annex_size :: Stat
|
||||
known_annex_size = stat "size of annexed files in working tree" $ json id $
|
||||
known_annex_size = simpleStat "size of annexed files in working tree" $
|
||||
showSizeKeys <$> cachedReferencedData
|
||||
|
||||
tmp_size :: Stat
|
||||
|
@ -206,8 +275,14 @@ tmp_size = staleSize "temporary object directory size" gitAnnexTmpObjectDir
|
|||
bad_data_size :: Stat
|
||||
bad_data_size = staleSize "bad keys size" gitAnnexBadDir
|
||||
|
||||
key_size :: Key -> Stat
|
||||
key_size k = simpleStat "size" $ pure $ showSizeKeys $ foldKeys [k]
|
||||
|
||||
key_name :: Key -> Stat
|
||||
key_name k = simpleStat "key" $ pure $ key2file k
|
||||
|
||||
bloom_info :: Stat
|
||||
bloom_info = stat "bloom filter size" $ json id $ do
|
||||
bloom_info = simpleStat "bloom filter size" $ do
|
||||
localkeys <- countKeys <$> cachedPresentData
|
||||
capacity <- fromIntegral <$> lift Command.Unused.bloomCapacity
|
||||
let note = aside $
|
||||
|
@ -240,7 +315,7 @@ transfer_list = stat "transfers in progress" $ nojson $ lift $ do
|
|||
]
|
||||
|
||||
disk_size :: Stat
|
||||
disk_size = stat "available local disk space" $ json id $ lift $
|
||||
disk_size = simpleStat "available local disk space" $ lift $
|
||||
calcfree
|
||||
<$> (annexDiskReserve <$> Annex.getGitConfig)
|
||||
<*> inRepo (getDiskFree . gitAnnexDir)
|
||||
|
@ -264,7 +339,7 @@ backend_usage = stat "backend usage" $ nojson $
|
|||
where
|
||||
calc x y = multiLine $
|
||||
map (\(n, b) -> b ++ ": " ++ show n) $
|
||||
reverse $ sort $ map swap $ M.toList $
|
||||
sortBy (flip compare) $ map swap $ M.toList $
|
||||
M.unionWith (+) x y
|
||||
|
||||
numcopies_stats :: Stat
|
||||
|
@ -273,7 +348,7 @@ numcopies_stats = stat "numcopies stats" $ nojson $
|
|||
where
|
||||
calc = multiLine
|
||||
. map (\(variance, count) -> show variance ++ ": " ++ show count)
|
||||
. reverse . sortBy (comparing snd) . M.toList
|
||||
. sortBy (flip (comparing snd)) . M.toList
|
||||
|
||||
cachedPresentData :: StatState KeyData
|
||||
cachedPresentData = do
|
||||
|
@ -296,12 +371,12 @@ cachedReferencedData = do
|
|||
put s { referencedData = Just v }
|
||||
return v
|
||||
|
||||
-- currently only available for local info
|
||||
-- currently only available for directory info
|
||||
cachedNumCopiesStats :: StatState (Maybe NumCopiesStats)
|
||||
cachedNumCopiesStats = numCopiesStats <$> get
|
||||
|
||||
getLocalStatInfo :: FilePath -> Annex StatInfo
|
||||
getLocalStatInfo dir = do
|
||||
getDirStatInfo :: FilePath -> Annex StatInfo
|
||||
getDirStatInfo dir = do
|
||||
fast <- Annex.getState Annex.fast
|
||||
matcher <- Limit.getMatcher
|
||||
(presentdata, referenceddata, numcopiesstats) <-
|
||||
|
|
|
@ -11,8 +11,8 @@ import Common.Annex
|
|||
import Command
|
||||
import Annex.Init
|
||||
|
||||
def :: [Command]
|
||||
def = [dontCheck repoExists $
|
||||
cmd :: [Command]
|
||||
cmd = [dontCheck repoExists $
|
||||
command "init" paramDesc seek SectionSetup "initialize git-annex"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -19,8 +19,8 @@ import Logs.Trust
|
|||
|
||||
import Data.Ord
|
||||
|
||||
def :: [Command]
|
||||
def = [command "initremote"
|
||||
cmd :: [Command]
|
||||
cmd = [command "initremote"
|
||||
(paramPair paramName $ paramOptional $ paramRepeating paramKeyValue)
|
||||
seek SectionSetup "creates a special (non-git) remote"]
|
||||
|
||||
|
@ -32,6 +32,9 @@ start [] = error "Specify a name for the remote."
|
|||
start (name:ws) = ifM (isJust <$> findExisting name)
|
||||
( error $ "There is already a special remote named \"" ++ name ++
|
||||
"\". (Use enableremote to enable an existing special remote.)"
|
||||
, do
|
||||
ifM (isJust <$> Remote.byNameOnly name)
|
||||
( error $ "There is already a remote named \"" ++ name ++ "\""
|
||||
, do
|
||||
let c = newConfig name
|
||||
t <- findType config
|
||||
|
@ -39,6 +42,7 @@ start (name:ws) = ifM (isJust <$> findExisting name)
|
|||
showStart "initremote" name
|
||||
next $ perform t name $ M.union config c
|
||||
)
|
||||
)
|
||||
where
|
||||
config = Logs.Remote.keyValToConfig ws
|
||||
|
||||
|
@ -63,7 +67,7 @@ findExisting name = do
|
|||
return $ headMaybe matches
|
||||
|
||||
newConfig :: String -> R.RemoteConfig
|
||||
newConfig name = M.singleton nameKey name
|
||||
newConfig = M.singleton nameKey
|
||||
|
||||
findByName :: String -> M.Map UUID R.RemoteConfig -> [(UUID, R.RemoteConfig)]
|
||||
findByName n = filter (matching . snd) . M.toList
|
||||
|
|
|
@ -23,8 +23,8 @@ import Annex.UUID
|
|||
import qualified Annex
|
||||
import Git.Types (RemoteName)
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ withOptions [allrepos] $ command "list" paramPaths seek
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ withOptions [allrepos] $ command "list" paramPaths seek
|
||||
SectionQuery "show which remotes contain files"]
|
||||
|
||||
allrepos :: Option
|
||||
|
|
|
@ -12,8 +12,8 @@ import Command
|
|||
import qualified Annex.Queue
|
||||
import qualified Annex
|
||||
|
||||
def :: [Command]
|
||||
def = [notDirect $ command "lock" paramPaths seek SectionCommon
|
||||
cmd :: [Command]
|
||||
cmd = [notDirect $ command "lock" paramPaths seek SectionCommon
|
||||
"undo unlock command"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -34,8 +34,8 @@ data RefChange = RefChange
|
|||
|
||||
type Outputter = Bool -> POSIXTime -> [UUID] -> Annex ()
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions options $
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions options $
|
||||
command "log" paramPaths seek SectionQuery "shows location log"]
|
||||
|
||||
options :: [Option]
|
||||
|
|
|
@ -12,8 +12,8 @@ import Command
|
|||
import Annex.CatFile
|
||||
import Types.Key
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ noCommit $ noMessages $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ noCommit $ noMessages $
|
||||
command "lookupkey" (paramRepeating paramFile) seek
|
||||
SectionPlumbing "looks up key used for file"]
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ import qualified Utility.Dot as Dot
|
|||
-- a link from the first repository to the second (its remote)
|
||||
data Link = Link Git.Repo Git.Repo
|
||||
|
||||
def :: [Command]
|
||||
def = [dontCheck repoExists $
|
||||
cmd :: [Command]
|
||||
cmd = [dontCheck repoExists $
|
||||
command "map" paramNothing seek SectionQuery
|
||||
"generate map of repositories"]
|
||||
|
||||
|
@ -194,11 +194,11 @@ tryScan r
|
|||
| Git.repoIsUrl r = return Nothing
|
||||
| otherwise = liftIO $ safely $ Git.Config.read r
|
||||
where
|
||||
pipedconfig cmd params = liftIO $ safely $
|
||||
pipedconfig pcmd params = liftIO $ safely $
|
||||
withHandle StdoutHandle createProcessSuccess p $
|
||||
Git.Config.hRead r
|
||||
where
|
||||
p = proc cmd $ toCommand params
|
||||
p = proc pcmd $ toCommand params
|
||||
|
||||
configlist = Ssh.onRemote r (pipedconfig, return Nothing) "configlist" [] []
|
||||
manualconfiglist = do
|
||||
|
@ -206,14 +206,15 @@ tryScan r
|
|||
sshparams <- Ssh.toRepo r gc [Param sshcmd]
|
||||
liftIO $ pipedconfig "ssh" sshparams
|
||||
where
|
||||
sshcmd = cddir ++ " && " ++
|
||||
"git config --null --list"
|
||||
sshcmd = "sh -c " ++ shellEscape
|
||||
(cddir ++ " && " ++ "git config --null --list")
|
||||
dir = Git.repoPath r
|
||||
cddir
|
||||
| "/~" `isPrefixOf` dir =
|
||||
let (userhome, reldir) = span (/= '/') (drop 1 dir)
|
||||
in "cd " ++ userhome ++ " && cd " ++ shellEscape (drop 1 reldir)
|
||||
| otherwise = "cd " ++ shellEscape dir
|
||||
in "cd " ++ userhome ++ " && " ++ cdto (drop 1 reldir)
|
||||
| otherwise = cdto dir
|
||||
cdto p = "if ! cd " ++ shellEscape p ++ " 2>/dev/null; then cd " ++ shellEscape p ++ ".git; fi"
|
||||
|
||||
-- First, try sshing and running git config manually,
|
||||
-- only fall back to git-annex-shell configlist if that
|
||||
|
|
|
@ -13,8 +13,8 @@ import qualified Annex.Branch
|
|||
import qualified Git.Branch
|
||||
import Command.Sync (prepMerge, mergeLocal)
|
||||
|
||||
def :: [Command]
|
||||
def = [command "merge" paramNothing seek SectionMaintenance
|
||||
cmd :: [Command]
|
||||
cmd = [command "merge" paramNothing seek SectionMaintenance
|
||||
"automatically merge changes from remotes"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -16,8 +16,8 @@ import Logs.MetaData
|
|||
import qualified Data.Set as S
|
||||
import Data.Time.Clock.POSIX
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions metaDataOptions $
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions metaDataOptions $
|
||||
command "metadata" paramPaths seek
|
||||
SectionMetaData "sets metadata of a file"]
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ import Annex.Content
|
|||
import qualified Command.ReKey
|
||||
import qualified Command.Fsck
|
||||
|
||||
def :: [Command]
|
||||
def = [notDirect $
|
||||
cmd :: [Command]
|
||||
cmd = [notDirect $
|
||||
command "migrate" paramPaths seek
|
||||
SectionUtility "switch data to different backend"]
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ import Annex.Content
|
|||
import qualified Annex
|
||||
import Config.NumCopies
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions (fromToOptions ++ keyOptions) $
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions (fromToOptions ++ keyOptions) $
|
||||
command "mirror" paramPaths seek
|
||||
SectionCommon "mirror content of files to/from another repository"]
|
||||
|
||||
|
@ -32,7 +32,7 @@ seek ps = do
|
|||
ps
|
||||
|
||||
start :: Maybe Remote -> Maybe Remote -> FilePath -> Key -> CommandStart
|
||||
start to from file key = startKey to from (Just file) key
|
||||
start to from file = startKey to from (Just file)
|
||||
|
||||
startKey :: Maybe Remote -> Maybe Remote -> Maybe FilePath -> Key -> CommandStart
|
||||
startKey to from afile key = do
|
||||
|
|
|
@ -17,8 +17,8 @@ import Annex.UUID
|
|||
import Annex.Transfer
|
||||
import Logs.Presence
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions moveOptions $ command "move" paramPaths seek
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions moveOptions $ command "move" paramPaths seek
|
||||
SectionCommon "move content of files to/from another repository"]
|
||||
|
||||
moveOptions :: [Option]
|
||||
|
@ -34,7 +34,7 @@ seek ps = do
|
|||
ps
|
||||
|
||||
start :: Maybe Remote -> Maybe Remote -> Bool -> FilePath -> Key -> CommandStart
|
||||
start to from move file key = start' to from move (Just file) key
|
||||
start to from move = start' to from move . Just
|
||||
|
||||
startKey :: Maybe Remote -> Maybe Remote -> Bool -> Key -> CommandStart
|
||||
startKey to from move = start' to from move Nothing
|
||||
|
@ -91,7 +91,7 @@ expectedPresent dest key = do
|
|||
return $ dest `elem` remotes
|
||||
|
||||
toPerform :: Remote -> Bool -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
|
||||
toPerform dest move key afile fastcheck isthere = do
|
||||
toPerform dest move key afile fastcheck isthere =
|
||||
case isthere of
|
||||
Left err -> do
|
||||
showNote err
|
||||
|
|
|
@ -19,8 +19,8 @@ import Control.Concurrent
|
|||
import Control.Concurrent.Async
|
||||
import Control.Concurrent.STM
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ command "notifychanges" paramNothing seek SectionPlumbing
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ command "notifychanges" paramNothing seek SectionPlumbing
|
||||
"sends notification when git refs are changed"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
@ -51,7 +51,7 @@ start = do
|
|||
|
||||
-- No messages need to be received from the caller,
|
||||
-- but when it closes the connection, notice and terminate.
|
||||
let receiver = forever $ void $ getLine
|
||||
let receiver = forever $ void getLine
|
||||
void $ liftIO $ concurrently sender receiver
|
||||
stop
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import Command
|
|||
import Config.NumCopies
|
||||
import Types.Messages
|
||||
|
||||
def :: [Command]
|
||||
def = [command "numcopies" paramNumber seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "numcopies" paramNumber seek
|
||||
SectionSetup "configure desired number of copies"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
@ -22,8 +22,7 @@ seek = withWords start
|
|||
|
||||
start :: [String] -> CommandStart
|
||||
start [] = startGet
|
||||
start [s] = do
|
||||
case readish s of
|
||||
start [s] = case readish s of
|
||||
Nothing -> error $ "Bad number: " ++ s
|
||||
Just n
|
||||
| n > 0 -> startSet n
|
||||
|
@ -39,9 +38,9 @@ startGet = next $ next $ do
|
|||
Annex.setOutput QuietOutput
|
||||
v <- getGlobalNumCopies
|
||||
case v of
|
||||
Just n -> liftIO $ putStrLn $ show $ fromNumCopies n
|
||||
Just n -> liftIO $ print $ fromNumCopies n
|
||||
Nothing -> do
|
||||
liftIO $ putStrLn $ "global numcopies is not set"
|
||||
liftIO $ putStrLn "global numcopies is not set"
|
||||
old <- deprecatedNumCopies
|
||||
case old of
|
||||
Nothing -> liftIO $ putStrLn "(default is 1)"
|
||||
|
|
|
@ -26,8 +26,8 @@ import Types.MetaData
|
|||
|
||||
import qualified Data.Set as S
|
||||
|
||||
def :: [Command]
|
||||
def = [command "pre-commit" paramPaths seek SectionPlumbing
|
||||
cmd :: [Command]
|
||||
cmd = [command "pre-commit" paramPaths seek SectionPlumbing
|
||||
"run by git pre-commit hook"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
@ -59,7 +59,7 @@ startIndirect f = next $ do
|
|||
next $ return True
|
||||
|
||||
startDirect :: [String] -> CommandStart
|
||||
startDirect _ = next $ next $ preCommitDirect
|
||||
startDirect _ = next $ next preCommitDirect
|
||||
|
||||
addViewMetaData :: View -> ViewedFile -> Key -> CommandStart
|
||||
addViewMetaData v f k = do
|
||||
|
|
|
@ -17,8 +17,8 @@ import Logs.Web
|
|||
import Logs.Location
|
||||
import Utility.CopyFile
|
||||
|
||||
def :: [Command]
|
||||
def = [notDirect $ command "rekey"
|
||||
cmd :: [Command]
|
||||
cmd = [notDirect $ command "rekey"
|
||||
(paramOptional $ paramRepeating $ paramPair paramPath paramKey)
|
||||
seek SectionPlumbing "change keys used for files"]
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ import qualified Types.Key
|
|||
import qualified Types.Backend
|
||||
import qualified Backend
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ command "recvkey" paramKey seek
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ command "recvkey" paramKey seek
|
||||
SectionPlumbing "runs rsync in server mode to receive content"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -14,8 +14,8 @@ import Annex.UUID
|
|||
import Types.UUID
|
||||
import qualified Remote
|
||||
|
||||
def :: [Command]
|
||||
def = [dontCheck repoExists $
|
||||
cmd :: [Command]
|
||||
cmd = [dontCheck repoExists $
|
||||
command "reinit" (paramUUID ++ " or " ++ paramDesc) seek SectionUtility ""]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -14,8 +14,8 @@ import Annex.Content
|
|||
import qualified Command.Fsck
|
||||
import qualified Backend
|
||||
|
||||
def :: [Command]
|
||||
def = [command "reinject" (paramPair "SRC" "DEST") seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "reinject" (paramPair "SRC" "DEST") seek
|
||||
SectionUtility "sets content of annexed file"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -11,8 +11,8 @@ import Common.Annex
|
|||
import Command
|
||||
import RemoteDaemon.Core
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ command "remotedaemon" paramNothing seek SectionPlumbing
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ command "remotedaemon" paramNothing seek SectionPlumbing
|
||||
"detects when remotes have changed, and fetches from them"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -16,8 +16,8 @@ import qualified Git.Ref
|
|||
import Git.Types
|
||||
import Annex.Version
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ dontCheck repoExists $
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ dontCheck repoExists $
|
||||
command "repair" paramNothing seek SectionMaintenance "recover broken git repository"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
@ -68,7 +68,7 @@ repairAnnexBranch modifiedbranches
|
|||
)
|
||||
)
|
||||
where
|
||||
okindex = Annex.Branch.withIndex $ inRepo $ Git.Repair.checkIndex
|
||||
okindex = Annex.Branch.withIndex $ inRepo Git.Repair.checkIndex
|
||||
commitindex = do
|
||||
Annex.Branch.forceCommit "committing index after git repository repair"
|
||||
liftIO $ putStrLn "Successfully recovered the git-annex branch using .git/annex/index"
|
||||
|
|
|
@ -14,12 +14,12 @@ import Git.Sha
|
|||
import qualified Git.Branch
|
||||
import Annex.AutoMerge
|
||||
|
||||
def :: [Command]
|
||||
def = [command "resolvemerge" paramNothing seek SectionPlumbing
|
||||
cmd :: [Command]
|
||||
cmd = [command "resolvemerge" paramNothing seek SectionPlumbing
|
||||
"resolve merge conflicts"]
|
||||
|
||||
seek :: CommandSeek
|
||||
seek ps = withNothing start ps
|
||||
seek = withNothing start
|
||||
|
||||
start :: CommandStart
|
||||
start = do
|
||||
|
|
|
@ -11,8 +11,8 @@ import Common.Annex
|
|||
import Command
|
||||
import Logs.Web
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $
|
||||
command "rmurl" (paramPair paramFile paramUrl) seek
|
||||
SectionCommon "record file is not available at url"]
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ import Types.Messages
|
|||
|
||||
import qualified Data.Set as S
|
||||
|
||||
def :: [Command]
|
||||
def = [command "schedule" (paramPair paramRemote (paramOptional paramExpression)) seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "schedule" (paramPair paramRemote (paramOptional paramExpression)) seek
|
||||
SectionSetup "get or set scheduled jobs"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -11,8 +11,8 @@ import Command
|
|||
import Types.TrustLevel
|
||||
import Command.Trust (trustCommand)
|
||||
|
||||
def :: [Command]
|
||||
def = [command "semitrust" (paramRepeating paramRemote) seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "semitrust" (paramRepeating paramRemote) seek
|
||||
SectionSetup "return repository to default trust level"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -16,8 +16,8 @@ import Annex.Transfer
|
|||
import qualified CmdLine.GitAnnexShell.Fields as Fields
|
||||
import Utility.Metered
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ command "sendkey" paramKey seek
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ command "sendkey" paramKey seek
|
||||
SectionPlumbing "runs rsync in server mode to send content"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -16,8 +16,8 @@ import qualified Git.LsFiles as LsFiles
|
|||
import qualified Git.Ref
|
||||
import qualified Git
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ noCommit $ noMessages $ withOptions [jsonOption] $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ noCommit $ noMessages $ withOptions [jsonOption] $
|
||||
command "status" paramPaths seek SectionCommon
|
||||
"show the working tree status"]
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ import Annex.Ssh
|
|||
|
||||
import Control.Concurrent.MVar
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions syncOptions $
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions syncOptions $
|
||||
command "sync" (paramOptional (paramRepeating paramRemote))
|
||||
seek SectionCommon "synchronize local repository with remotes"]
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import Common
|
|||
import Command
|
||||
import Messages
|
||||
|
||||
def :: [Command]
|
||||
def = [ noRepo startIO $ dontCheck repoExists $
|
||||
cmd :: [Command]
|
||||
cmd = [ noRepo startIO $ dontCheck repoExists $
|
||||
command "test" paramNothing seek SectionTesting
|
||||
"run built-in test suite"]
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ import qualified Data.ByteString as B
|
|||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Data.Map as M
|
||||
|
||||
def :: [Command]
|
||||
def = [ withOptions [sizeOption] $
|
||||
cmd :: [Command]
|
||||
cmd = [ withOptions [sizeOption] $
|
||||
command "testremote" paramRemote seek SectionTesting
|
||||
"test transfers to/from a remote"]
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ import Types.Key
|
|||
import qualified CmdLine.GitAnnexShell.Fields as Fields
|
||||
import Utility.Metered
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ command "transferinfo" paramKey seek SectionPlumbing
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ command "transferinfo" paramKey seek SectionPlumbing
|
||||
"updates sender on number of bytes of content received"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -15,8 +15,8 @@ import Annex.Transfer
|
|||
import qualified Remote
|
||||
import Types.Remote
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions transferKeyOptions $
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions transferKeyOptions $
|
||||
noCommit $ command "transferkey" paramKey seek SectionPlumbing
|
||||
"transfers a key from or to a remote"]
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ import Git.Types (RemoteName)
|
|||
|
||||
data TransferRequest = TransferRequest Direction Remote Key AssociatedFile
|
||||
|
||||
def :: [Command]
|
||||
def = [command "transferkeys" paramNothing seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "transferkeys" paramNothing seek
|
||||
SectionPlumbing "transfers keys"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -16,19 +16,19 @@ import Logs.Group
|
|||
|
||||
import qualified Data.Set as S
|
||||
|
||||
def :: [Command]
|
||||
def = [command "trust" (paramRepeating paramRemote) seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "trust" (paramRepeating paramRemote) seek
|
||||
SectionSetup "trust a repository"]
|
||||
|
||||
seek :: CommandSeek
|
||||
seek = trustCommand "trust" Trusted
|
||||
|
||||
trustCommand :: String -> TrustLevel -> CommandSeek
|
||||
trustCommand cmd level = withWords start
|
||||
trustCommand c level = withWords start
|
||||
where
|
||||
start ws = do
|
||||
let name = unwords ws
|
||||
showStart cmd name
|
||||
showStart c name
|
||||
u <- Remote.nameToUUID name
|
||||
next $ perform u
|
||||
perform uuid = do
|
||||
|
|
|
@ -22,8 +22,8 @@ import qualified Git.DiffTree as DiffTree
|
|||
import Utility.CopyFile
|
||||
import Command.PreCommit (lockPreCommitHook)
|
||||
|
||||
def :: [Command]
|
||||
def = [command "unannex" paramPaths seek SectionUtility
|
||||
cmd :: [Command]
|
||||
cmd = [command "unannex" paramPaths seek SectionUtility
|
||||
"undo accidential add command"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -15,8 +15,8 @@ import Types.Group
|
|||
|
||||
import qualified Data.Set as S
|
||||
|
||||
def :: [Command]
|
||||
def = [command "ungroup" (paramPair paramRemote paramDesc) seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "ungroup" (paramPair paramRemote paramDesc) seek
|
||||
SectionSetup "remove a repository from a group"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -21,8 +21,8 @@ import Utility.FileMode
|
|||
import System.IO.HVFS
|
||||
import System.IO.HVFS.Utils
|
||||
|
||||
def :: [Command]
|
||||
def = [addCheck check $ command "uninit" paramPaths seek
|
||||
cmd :: [Command]
|
||||
cmd = [addCheck check $ command "uninit" paramPaths seek
|
||||
SectionUtility "de-initialize git-annex and clean out repository"]
|
||||
|
||||
check :: Annex ()
|
||||
|
|
|
@ -12,8 +12,8 @@ import Command
|
|||
import Annex.Content
|
||||
import Utility.CopyFile
|
||||
|
||||
def :: [Command]
|
||||
def =
|
||||
cmd :: [Command]
|
||||
cmd =
|
||||
[ c "unlock" "unlock files for modification"
|
||||
, c "edit" "same as unlock"
|
||||
]
|
||||
|
|
|
@ -11,8 +11,8 @@ import Command
|
|||
import Types.TrustLevel
|
||||
import Command.Trust (trustCommand)
|
||||
|
||||
def :: [Command]
|
||||
def = [command "untrust" (paramRepeating paramRemote) seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "untrust" (paramRepeating paramRemote) seek
|
||||
SectionSetup "do not trust a repository"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -35,8 +35,8 @@ import Git.FilePath
|
|||
import Logs.View (is_branchView)
|
||||
import Utility.Bloom
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions [unusedFromOption] $ command "unused" paramNothing seek
|
||||
cmd :: [Command]
|
||||
cmd = [withOptions [unusedFromOption] $ command "unused" paramNothing seek
|
||||
SectionMaintenance "look for unused file content"]
|
||||
|
||||
unusedFromOption :: Option
|
||||
|
|
|
@ -11,8 +11,8 @@ import Common.Annex
|
|||
import Command
|
||||
import Upgrade
|
||||
|
||||
def :: [Command]
|
||||
def = [dontCheck repoExists $ -- because an old version may not seem to exist
|
||||
cmd :: [Command]
|
||||
cmd = [dontCheck repoExists $ -- because an old version may not seem to exist
|
||||
command "upgrade" paramNothing seek
|
||||
SectionMaintenance "upgrade repository layout"]
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ import Command
|
|||
import Annex.View
|
||||
import Command.View (checkoutViewBranch)
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ notDirect $ command "vadd" (paramRepeating "FIELD=GLOB")
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ notDirect $ command "vadd" (paramRepeating "FIELD=GLOB")
|
||||
seek SectionMetaData "add subdirs to current view"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -14,8 +14,8 @@ import Types.View
|
|||
import Logs.View
|
||||
import Command.View (checkoutViewBranch)
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ notDirect $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ notDirect $
|
||||
command "vcycle" paramNothing seek SectionUtility
|
||||
"switch view to next layout"]
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ import Command
|
|||
import Annex.View
|
||||
import Command.View (paramView, checkoutViewBranch)
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ notDirect $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ notDirect $
|
||||
command "vfilter" paramView seek SectionMetaData "filter current view"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -16,8 +16,8 @@ import Types.View
|
|||
import Logs.View
|
||||
import Command.View (checkoutViewBranch)
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ notDirect $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ notDirect $
|
||||
command "vpop" (paramOptional paramNumber) seek SectionMetaData
|
||||
"switch back to previous view"]
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ import qualified Types.Remote as R
|
|||
import qualified Remote
|
||||
import qualified Backend
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
||||
command "version" paramNothing seek SectionQuery "show version info"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
|
||||
module Command.Vicfg where
|
||||
|
||||
import qualified Data.Map as M
|
||||
|
@ -12,6 +14,7 @@ import qualified Data.Set as S
|
|||
import System.Environment (getEnv)
|
||||
import Data.Tuple (swap)
|
||||
import Data.Char (isSpace)
|
||||
import Data.Default
|
||||
|
||||
import Common.Annex
|
||||
import Command
|
||||
|
@ -26,8 +29,8 @@ import Types.StandardGroups
|
|||
import Types.ScheduledActivity
|
||||
import Remote
|
||||
|
||||
def :: [Command]
|
||||
def = [command "vicfg" paramNothing seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "vicfg" paramNothing seek
|
||||
SectionSetup "edit git-annex's configuration"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
@ -49,7 +52,7 @@ vicfg curcfg f = do
|
|||
-- Allow EDITOR to be processed by the shell, so it can contain options.
|
||||
unlessM (liftIO $ boolSystem "sh" [Param "-c", Param $ unwords [vi, shellEscape f]]) $
|
||||
error $ vi ++ " exited nonzero; aborting"
|
||||
r <- parseCfg curcfg <$> liftIO (readFileStrict f)
|
||||
r <- parseCfg (defCfg curcfg) <$> liftIO (readFileStrict f)
|
||||
liftIO $ nukeFile f
|
||||
case r of
|
||||
Left s -> do
|
||||
|
@ -85,6 +88,21 @@ setCfg curcfg newcfg = do
|
|||
mapM_ (uncurry groupPreferredContentSet) $ M.toList $ cfgGroupPreferredContentMap diff
|
||||
mapM_ (uncurry scheduleSet) $ M.toList $ cfgScheduleMap diff
|
||||
|
||||
{- Default config has all the keys from the input config, but with their
|
||||
- default values. -}
|
||||
defCfg :: Cfg -> Cfg
|
||||
defCfg curcfg = Cfg
|
||||
{ cfgTrustMap = mapdef $ cfgTrustMap curcfg
|
||||
, cfgGroupMap = mapdef $ cfgGroupMap curcfg
|
||||
, cfgPreferredContentMap = mapdef $ cfgPreferredContentMap curcfg
|
||||
, cfgRequiredContentMap = mapdef $ cfgRequiredContentMap curcfg
|
||||
, cfgGroupPreferredContentMap = mapdef $ cfgGroupPreferredContentMap curcfg
|
||||
, cfgScheduleMap = mapdef $ cfgScheduleMap curcfg
|
||||
}
|
||||
where
|
||||
mapdef :: forall k v. Default v => M.Map k v -> M.Map k v
|
||||
mapdef = M.map (const def)
|
||||
|
||||
diffCfg :: Cfg -> Cfg -> Cfg
|
||||
diffCfg curcfg newcfg = Cfg
|
||||
{ cfgTrustMap = diff cfgTrustMap
|
||||
|
@ -124,7 +142,7 @@ genCfg cfg descs = unlines $ intercalate [""]
|
|||
, com "(Valid trust levels: " ++ trustlevels ++ ")"
|
||||
]
|
||||
(\(t, u) -> line "trust" u $ showTrustLevel t)
|
||||
(\u -> lcom $ line "trust" u $ showTrustLevel SemiTrusted)
|
||||
(\u -> lcom $ line "trust" u $ showTrustLevel def)
|
||||
where
|
||||
trustlevels = unwords $ map showTrustLevel [Trusted .. DeadTrusted]
|
||||
|
||||
|
@ -203,7 +221,7 @@ lcom = map (\l -> if "#" `isPrefixOf` l then l else '#' : l)
|
|||
{- If there's a parse error, returns a new version of the file,
|
||||
- with the problem lines noted. -}
|
||||
parseCfg :: Cfg -> String -> Either String Cfg
|
||||
parseCfg curcfg = go [] curcfg . lines
|
||||
parseCfg defcfg = go [] defcfg . lines
|
||||
where
|
||||
go c cfg []
|
||||
| null (mapMaybe fst c) = Right cfg
|
||||
|
|
|
@ -17,8 +17,8 @@ import Types.View
|
|||
import Annex.View
|
||||
import Logs.View
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ notDirect $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ notDirect $
|
||||
command "view" paramView seek SectionMetaData "enter a view branch"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
@ -42,7 +42,7 @@ perform view = do
|
|||
next $ checkoutViewBranch view applyView
|
||||
|
||||
paramView :: String
|
||||
paramView = paramPair (paramRepeating "TAG") (paramRepeating "FIELD=VALUE")
|
||||
paramView = paramRepeating "FIELD=VALUE"
|
||||
|
||||
mkView :: [String] -> Annex View
|
||||
mkView params = go =<< inRepo Git.Branch.current
|
||||
|
|
|
@ -16,8 +16,8 @@ import Types.Messages
|
|||
|
||||
import qualified Data.Map as M
|
||||
|
||||
def :: [Command]
|
||||
def = [command "wanted" (paramPair paramRemote (paramOptional paramExpression)) seek
|
||||
cmd :: [Command]
|
||||
cmd = [command "wanted" (paramPair paramRemote (paramOptional paramExpression)) seek
|
||||
SectionSetup "get or set preferred content expression"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -12,8 +12,8 @@ import Assistant
|
|||
import Command
|
||||
import Utility.HumanTime
|
||||
|
||||
def :: [Command]
|
||||
def = [notBareRepo $ withOptions [foregroundOption, stopOption] $
|
||||
cmd :: [Command]
|
||||
cmd = [notBareRepo $ withOptions [foregroundOption, stopOption] $
|
||||
command "watch" paramNothing seek SectionCommon "watch for changes"]
|
||||
|
||||
seek :: CommandSeek
|
||||
|
|
|
@ -37,8 +37,8 @@ import Control.Concurrent.STM
|
|||
import Network.Socket (HostName)
|
||||
import System.Environment (getArgs)
|
||||
|
||||
def :: [Command]
|
||||
def = [ withOptions [listenOption] $
|
||||
cmd :: [Command]
|
||||
cmd = [ withOptions [listenOption] $
|
||||
noCommit $ noRepo startNoRepo $ dontCheck repoExists $ notBareRepo $
|
||||
command "webapp" paramNothing seek SectionCommon "launch webapp"]
|
||||
|
||||
|
@ -213,7 +213,7 @@ openBrowser mcmd htmlshim realurl outh errh = do
|
|||
#endif
|
||||
where
|
||||
p = case mcmd of
|
||||
Just cmd -> proc cmd [htmlshim]
|
||||
Just c -> proc c [htmlshim]
|
||||
Nothing ->
|
||||
#ifndef mingw32_HOST_OS
|
||||
browserProc url
|
||||
|
|
|
@ -14,8 +14,8 @@ import Command
|
|||
import Remote
|
||||
import Logs.Trust
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ withOptions (jsonOption : keyOptions) $
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ withOptions (jsonOption : keyOptions) $
|
||||
command "whereis" paramPaths seek SectionQuery
|
||||
"lists repositories that have file content"]
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import Common.Annex
|
|||
import Command
|
||||
import Assistant.XMPP.Git
|
||||
|
||||
def :: [Command]
|
||||
def = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
||||
command "xmppgit" paramNothing seek
|
||||
SectionPlumbing "git to XMPP relay"]
|
||||
|
||||
|
@ -37,9 +37,9 @@ gitRemoteHelper = do
|
|||
respond []
|
||||
where
|
||||
expect s = do
|
||||
cmd <- getLine
|
||||
unless (cmd == s) $
|
||||
error $ "git-remote-helpers protocol error: expected: " ++ s ++ ", but got: " ++ cmd
|
||||
gitcmd <- getLine
|
||||
unless (gitcmd == s) $
|
||||
error $ "git-remote-helpers protocol error: expected: " ++ s ++ ", but got: " ++ gitcmd
|
||||
respond l = do
|
||||
mapM_ putStrLn l
|
||||
putStrLn ""
|
||||
|
|
86
Creds.hs
86
Creds.hs
|
@ -15,6 +15,7 @@ module Creds (
|
|||
writeCacheCreds,
|
||||
readCacheCreds,
|
||||
removeCreds,
|
||||
includeCredsInfo,
|
||||
) where
|
||||
|
||||
import Common.Annex
|
||||
|
@ -23,7 +24,7 @@ import Annex.Perms
|
|||
import Utility.FileMode
|
||||
import Crypto
|
||||
import Types.Remote (RemoteConfig, RemoteConfigKey)
|
||||
import Remote.Helper.Encryptable (remoteCipher, remoteCipher', embedCreds)
|
||||
import Remote.Helper.Encryptable (remoteCipher, remoteCipher', embedCreds, EncryptionIsSetup, extractCipher)
|
||||
import Utility.Env (getEnv)
|
||||
|
||||
import qualified Data.ByteString.Lazy.Char8 as L
|
||||
|
@ -39,16 +40,23 @@ data CredPairStorage = CredPairStorage
|
|||
}
|
||||
|
||||
{- Stores creds in a remote's configuration, if the remote allows
|
||||
- that. Otherwise, caches them locally.
|
||||
- The creds are found in storage if not provided. -}
|
||||
setRemoteCredPair :: RemoteConfig -> CredPairStorage -> Maybe CredPair -> Annex RemoteConfig
|
||||
setRemoteCredPair c storage Nothing =
|
||||
maybe (return c) (setRemoteCredPair c storage . Just)
|
||||
- that. Also caches them locally.
|
||||
-
|
||||
- The creds are found from the CredPairStorage storage if not provided,
|
||||
- so may be provided by an environment variable etc.
|
||||
-
|
||||
- The remote's configuration should have already had a cipher stored in it
|
||||
- if that's going to be done, so that the creds can be encrypted using the
|
||||
- cipher. The EncryptionIsSetup phantom type ensures that is the case.
|
||||
-}
|
||||
setRemoteCredPair :: EncryptionIsSetup -> RemoteConfig -> CredPairStorage -> Maybe CredPair -> Annex RemoteConfig
|
||||
setRemoteCredPair encsetup c storage Nothing =
|
||||
maybe (return c) (setRemoteCredPair encsetup c storage . Just)
|
||||
=<< getRemoteCredPair c storage
|
||||
setRemoteCredPair c storage (Just creds)
|
||||
setRemoteCredPair _ c storage (Just creds)
|
||||
| embedCreds c = case credPairRemoteKey storage of
|
||||
Nothing -> localcache
|
||||
Just key -> storeconfig key =<< remoteCipher c
|
||||
Just key -> storeconfig key =<< remoteCipher =<< localcache
|
||||
| otherwise = localcache
|
||||
where
|
||||
localcache = do
|
||||
|
@ -86,23 +94,31 @@ getRemoteCredPair c storage = maybe fromcache (return . Just) =<< fromenv
|
|||
fromconfig = case credPairRemoteKey storage of
|
||||
Just key -> do
|
||||
mcipher <- remoteCipher' c
|
||||
case (mcipher, M.lookup key c) of
|
||||
(_, Nothing) -> return Nothing
|
||||
(Just (_cipher, SharedCipher {}), Just bcreds) ->
|
||||
-- When using a shared cipher, the
|
||||
-- creds are not stored encrypted.
|
||||
fromcreds $ fromB64 bcreds
|
||||
(Just (cipher, _), Just enccreds) -> do
|
||||
creds <- liftIO $ decrypt cipher
|
||||
(feedBytes $ L.pack $ fromB64 enccreds)
|
||||
(readBytes $ return . L.unpack)
|
||||
fromcreds creds
|
||||
(Nothing, Just bcreds) ->
|
||||
case (M.lookup key c, mcipher) of
|
||||
(Nothing, _) -> return Nothing
|
||||
(Just enccreds, Just (cipher, storablecipher)) ->
|
||||
fromenccreds enccreds cipher storablecipher
|
||||
(Just bcreds, Nothing) ->
|
||||
fromcreds $ fromB64 bcreds
|
||||
Nothing -> return Nothing
|
||||
fromenccreds enccreds cipher storablecipher = do
|
||||
mcreds <- liftIO $ catchMaybeIO $ decrypt cipher
|
||||
(feedBytes $ L.pack $ fromB64 enccreds)
|
||||
(readBytes $ return . L.unpack)
|
||||
case mcreds of
|
||||
Just creds -> fromcreds creds
|
||||
Nothing -> do
|
||||
-- Work around un-encrypted creds storage
|
||||
-- bug in old S3 and glacier remotes.
|
||||
-- Not a problem for shared cipher.
|
||||
case storablecipher of
|
||||
SharedCipher {} -> showLongNote "gpg error above was caused by an old git-annex bug in credentials storage. Working around it.."
|
||||
_ -> error "*** Insecure credentials storage detected for this remote! See https://git-annex.branchable.com/upgrades/insecure_embedded_creds/"
|
||||
fromcreds $ fromB64 enccreds
|
||||
fromcreds creds = case decodeCredPair creds of
|
||||
Just credpair -> do
|
||||
writeCacheCredPair credpair storage
|
||||
|
||||
return $ Just credpair
|
||||
_ -> error "bad creds"
|
||||
|
||||
|
@ -131,10 +147,16 @@ readCacheCredPair storage = maybe Nothing decodeCredPair
|
|||
<$> readCacheCreds (credPairFile storage)
|
||||
|
||||
readCacheCreds :: FilePath -> Annex (Maybe Creds)
|
||||
readCacheCreds file = do
|
||||
readCacheCreds f = liftIO . catchMaybeIO . readFile =<< cacheCredsFile f
|
||||
|
||||
cacheCredsFile :: FilePath -> Annex FilePath
|
||||
cacheCredsFile basefile = do
|
||||
d <- fromRepo gitAnnexCredsDir
|
||||
let f = d </> file
|
||||
liftIO $ catchMaybeIO $ readFile f
|
||||
return $ d </> basefile
|
||||
|
||||
existsCacheCredPair :: CredPairStorage -> Annex Bool
|
||||
existsCacheCredPair storage =
|
||||
liftIO . doesFileExist =<< cacheCredsFile (credPairFile storage)
|
||||
|
||||
encodeCredPair :: CredPair -> Creds
|
||||
encodeCredPair (l, p) = unlines [l, p]
|
||||
|
@ -149,3 +171,21 @@ removeCreds file = do
|
|||
d <- fromRepo gitAnnexCredsDir
|
||||
let f = d </> file
|
||||
liftIO $ nukeFile f
|
||||
|
||||
includeCredsInfo :: RemoteConfig -> CredPairStorage -> [(String, String)] -> Annex [(String, String)]
|
||||
includeCredsInfo c storage info = do
|
||||
v <- liftIO $ getEnvCredPair storage
|
||||
case v of
|
||||
Just _ -> do
|
||||
let (uenv, penv) = credPairEnvironment storage
|
||||
ret $ "from environment variables (" ++ unwords [uenv, penv] ++ ")"
|
||||
Nothing -> case (\ck -> M.lookup ck c) =<< credPairRemoteKey storage of
|
||||
Nothing -> ifM (existsCacheCredPair storage)
|
||||
( ret "stored locally"
|
||||
, ret "not available"
|
||||
)
|
||||
Just _ -> case extractCipher c of
|
||||
Just (EncryptedCipher _ _ _) -> ret "embedded in git repository (gpg encrypted)"
|
||||
_ -> ret "embedded in git repository (not encrypted)"
|
||||
where
|
||||
ret s = return $ ("creds", s) : info
|
||||
|
|
|
@ -5,17 +5,13 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module Git.CurrentRepo where
|
||||
|
||||
import Common
|
||||
import Git.Types
|
||||
import Git.Construct
|
||||
import qualified Git.Config
|
||||
#ifndef mingw32_HOST_OS
|
||||
import Utility.Env
|
||||
#endif
|
||||
|
||||
{- Gets the current git repository.
|
||||
-
|
||||
|
@ -42,17 +38,13 @@ get = do
|
|||
setCurrentDirectory d
|
||||
return $ addworktree wt r
|
||||
where
|
||||
#ifndef mingw32_HOST_OS
|
||||
pathenv s = do
|
||||
v <- getEnv s
|
||||
case v of
|
||||
Just d -> do
|
||||
void $ unsetEnv s
|
||||
unsetEnv s
|
||||
Just <$> absPath d
|
||||
Nothing -> return Nothing
|
||||
#else
|
||||
pathenv _ = return Nothing
|
||||
#endif
|
||||
|
||||
configure Nothing (Just r) = Git.Config.read r
|
||||
configure (Just d) _ = do
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue