1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Trying to surface error

This commit is contained in:
Rick Winfrey 2017-03-23 17:05:57 -07:00
parent 1604f6ca34
commit 3b8553f912
3 changed files with 8 additions and 7 deletions

View File

@ -182,6 +182,7 @@ test-suite test
, regex-compat
, semantic-diff
, text >= 1.2.1.3
, unordered-containers
, these
, vector
ghc-options: -threaded -rtsopts -with-rtsopts=-N -j -pgml=script/g++

View File

@ -1,5 +1,5 @@
-- | We use BangPatterns to force evaluation of git operations to preserve accuracy in measuring system stats (particularly disk read bytes)
{-# LANGUAGE RecordWildCards, BangPatterns, DeriveGeneric, RankNTypes #-}
{-# LANGUAGE RecordWildCards, DeriveGeneric, RankNTypes #-}
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
module GitmonClient where
@ -85,8 +85,7 @@ reportGitmon' SocketFactory{..} program gitCommand =
gitmonStatus <- safeGitmonIO $ recv socket' 1024
(startTime, beforeProcIOContents) <- collectStats
-- | We are eagerly evaluating the gitCommand with BangPatterns. This is to preserve accuracy in measuring the process stats calculated, in particular disk read bytes.
let !result = withGitmonStatus gitmonStatus gitCommand
let result = withGitmonStatus gitmonStatus gitCommand
(afterTime, afterProcIOContents) <- collectStats
let (cpuTime, diskReadBytes, diskWriteBytes, resultCode) = procStats startTime afterTime beforeProcIOContents afterProcIOContents

View File

@ -5,8 +5,9 @@ import Data.Aeson
import Data.Aeson.Types
import Data.ByteString.Char8 (ByteString, pack, unpack)
import Data.Foldable
import Data.Maybe (fromJust)
import Data.Text
import Data.HashMap.Lazy (empty)
import Data.Maybe (fromJust, fromMaybe)
import Data.Text hiding (empty)
import Git.Libgit2
import Git.Repository
import Git.Types hiding (Object)
@ -201,10 +202,10 @@ infoToData input = data' . toObject <$> extract regex input
]
toObject :: ByteString -> Object
toObject = fromJust . decodeStrict
toObject input = fromMaybe empty (decodeStrict input)
regex :: Regex
regex = mkRegexWithOpts "({.*\"update\".*\"}})({.*\"schedule\"})({.*\"finish\".*}})" False True
extract :: Regex -> ByteString -> [ByteString]
extract regex input = Data.ByteString.Char8.pack <$> fromJust (matchRegex regex (Data.ByteString.Char8.unpack input))
extract regex input = Data.ByteString.Char8.pack <$> fromMaybe [""] (matchRegex regex (Data.ByteString.Char8.unpack input))