add back debug logging
Make Utility.Process wrap the parts of System.Process that I use, and add debug logging to them. Also wrote some higher-level code that allows running an action with handles to a processes stdin or stdout (or both), and checking its exit status, all in a single function call. As a bonus, the debug logging now indicates whether the process is being run to read from it, feed it data, chat with it (writing and reading), or just call it for its side effect.
This commit is contained in:
parent
549f861999
commit
1db7d27a45
17 changed files with 251 additions and 126 deletions
|
@ -7,7 +7,6 @@
|
|||
|
||||
module Git.Command where
|
||||
|
||||
import System.Process
|
||||
import System.Posix.Process (getAnyProcessStatus)
|
||||
|
||||
import Common
|
||||
|
@ -41,12 +40,12 @@ run subcommand params repo = assertLocal repo $
|
|||
- result unless reap is called.
|
||||
-}
|
||||
pipeRead :: [CommandParam] -> Repo -> IO String
|
||||
pipeRead params repo = assertLocal repo $ do
|
||||
(_, Just h, _, _) <- createProcess
|
||||
(proc "git" $ toCommand $ gitCommandLine params repo)
|
||||
{ std_out = CreatePipe }
|
||||
fileEncoding h
|
||||
hGetContents h
|
||||
pipeRead params repo = assertLocal repo $
|
||||
withHandle StdoutHandle createBackgroundProcess p $ \h -> do
|
||||
fileEncoding h
|
||||
hGetContents h
|
||||
where
|
||||
p = proc "git" $ toCommand $ gitCommandLine params repo
|
||||
|
||||
{- Runs a git subcommand, feeding it input, and returning its output,
|
||||
- which is expected to be fairly small, since it's all read into memory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue