handle git-credential prompt in -J mode
If git-credential has it cached and does not prompt, this will unfortunately result in a brief flicker, as the displayed console regions are hidden while running it and then re-displayed. Better than a corrupted display. Actually, I tried it and don't see a visible flicker, so probably only over a slow ssh will it be apparent.
This commit is contained in:
parent
1883f7ef8f
commit
6f90bb7738
4 changed files with 30 additions and 16 deletions
|
@ -133,12 +133,15 @@ withUrlOptionsPromptingCreds :: (U.UrlOptions -> Annex a) -> Annex a
|
||||||
withUrlOptionsPromptingCreds a = do
|
withUrlOptionsPromptingCreds a = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
uo <- getUrlOptions
|
uo <- getUrlOptions
|
||||||
|
prompter <- mkPrompter
|
||||||
a $ uo
|
a $ uo
|
||||||
{ U.getBasicAuth = getBasicAuthFromCredential g
|
{ U.getBasicAuth = \u -> prompter $
|
||||||
|
getBasicAuthFromCredential g u
|
||||||
-- Can't download with curl and handle basic auth,
|
-- Can't download with curl and handle basic auth,
|
||||||
-- so avoid using curl.
|
-- so make sure it uses conduit.
|
||||||
, U.urlDownloader = case U.urlDownloader uo of
|
, U.urlDownloader = case U.urlDownloader uo of
|
||||||
U.DownloadWithCurl _ -> U.DownloadWithConduit $ U.DownloadWithCurlRestricted mempty
|
U.DownloadWithCurl _ -> U.DownloadWithConduit $
|
||||||
|
U.DownloadWithCurlRestricted mempty
|
||||||
v -> v
|
v -> v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
Messages.hs
17
Messages.hs
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex output messages
|
{- git-annex output messages
|
||||||
-
|
-
|
||||||
- Copyright 2010-2019 Joey Hess <id@joeyh.name>
|
- Copyright 2010-2020 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -48,6 +48,7 @@ module Messages (
|
||||||
outputMessage,
|
outputMessage,
|
||||||
withMessageState,
|
withMessageState,
|
||||||
prompt,
|
prompt,
|
||||||
|
mkPrompter,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import System.Log.Logger
|
import System.Log.Logger
|
||||||
|
@ -55,6 +56,7 @@ import System.Log.Formatter
|
||||||
import System.Log.Handler (setFormatter)
|
import System.Log.Handler (setFormatter)
|
||||||
import System.Log.Handler.Simple
|
import System.Log.Handler.Simple
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
|
import Control.Monad.IO.Class
|
||||||
import qualified Data.ByteString as S
|
import qualified Data.ByteString as S
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
@ -290,14 +292,21 @@ commandProgressDisabled = withMessageState $ \s -> return $
|
||||||
- the user.
|
- the user.
|
||||||
-}
|
-}
|
||||||
prompt :: Annex a -> Annex a
|
prompt :: Annex a -> Annex a
|
||||||
prompt a = debugLocks $ Annex.getState Annex.concurrency >>= \case
|
prompt a = do
|
||||||
NonConcurrent -> a
|
p <- mkPrompter
|
||||||
|
p a
|
||||||
|
|
||||||
|
{- Like prompt, but for a non-annex action that prompts. -}
|
||||||
|
mkPrompter :: (MonadMask m, MonadIO m) => Annex (m a -> m a)
|
||||||
|
mkPrompter = Annex.getState Annex.concurrency >>= \case
|
||||||
|
NonConcurrent -> return id
|
||||||
(Concurrent _) -> goconcurrent
|
(Concurrent _) -> goconcurrent
|
||||||
ConcurrentPerCpu -> goconcurrent
|
ConcurrentPerCpu -> goconcurrent
|
||||||
where
|
where
|
||||||
goconcurrent = withMessageState $ \s -> do
|
goconcurrent = withMessageState $ \s -> do
|
||||||
let l = promptLock s
|
let l = promptLock s
|
||||||
bracketIO
|
return $ \a ->
|
||||||
|
debugLocks $ bracketIO
|
||||||
(takeMVar l)
|
(takeMVar l)
|
||||||
(putMVar l)
|
(putMVar l)
|
||||||
(const $ hideRegionsWhile s a)
|
(const $ hideRegionsWhile s a)
|
||||||
|
|
|
@ -18,6 +18,7 @@ import Common
|
||||||
import qualified System.Console.Concurrent as Console
|
import qualified System.Console.Concurrent as Console
|
||||||
import qualified System.Console.Regions as Regions
|
import qualified System.Console.Regions as Regions
|
||||||
import Control.Concurrent.STM
|
import Control.Concurrent.STM
|
||||||
|
import Control.Monad.IO.Class
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
import GHC.IO.Encoding
|
import GHC.IO.Encoding
|
||||||
|
@ -120,13 +121,14 @@ concurrentOutputSupported = return True -- Windows is always unicode
|
||||||
|
|
||||||
{- Hide any currently displayed console regions while running the action,
|
{- Hide any currently displayed console regions while running the action,
|
||||||
- so that the action can use the console itself. -}
|
- so that the action can use the console itself. -}
|
||||||
hideRegionsWhile :: MessageState -> Annex a -> Annex a
|
hideRegionsWhile :: (MonadIO m, Monad m, MonadMask m) => MessageState -> m a -> m a
|
||||||
hideRegionsWhile s a
|
hideRegionsWhile s a
|
||||||
| concurrentOutputEnabled s = bracketIO setup cleanup go
|
| concurrentOutputEnabled s = bracket setup cleanup go
|
||||||
| otherwise = a
|
| otherwise = a
|
||||||
where
|
where
|
||||||
setup = Regions.waitDisplayChange $ swapTMVar Regions.regionList []
|
setup = liftIO $
|
||||||
cleanup = void . atomically . swapTMVar Regions.regionList
|
Regions.waitDisplayChange $ swapTMVar Regions.regionList []
|
||||||
|
cleanup = liftIO . void . atomically . swapTMVar Regions.regionList
|
||||||
go _ = do
|
go _ = do
|
||||||
liftIO $ hFlush stdout
|
liftIO $ hFlush stdout
|
||||||
a
|
a
|
||||||
|
|
|
@ -510,7 +510,7 @@ downloadConduit meterupdate req file uo =
|
||||||
case r of
|
case r of
|
||||||
Right () -> signalsuccess True
|
Right () -> signalsuccess True
|
||||||
Left e -> do
|
Left e -> do
|
||||||
signalsuccess False
|
() <- signalsuccess False
|
||||||
throwM e
|
throwM e
|
||||||
|
|
||||||
{- Sinks a Response's body to a file. The file can either be opened in
|
{- Sinks a Response's body to a file. The file can either be opened in
|
||||||
|
|
Loading…
Reference in a new issue