1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 04:51:57 +03:00

Merge pull request #2243 from github/break-dependency-of-config-on-SHA

Break dependency of Semantic.Config on Semantic.Version/buildSHA
This commit is contained in:
Rob Rix 2018-10-30 23:03:19 -04:00 committed by GitHub
commit a0643b725a
3 changed files with 13 additions and 5 deletions

View File

@ -6,6 +6,7 @@ module Semantic.CLI
, Parse.runParse
) where
import Control.Exception as Exc (displayException)
import Data.File
import Data.Language (ensureLanguage, languageForFilePath)
import Data.List (intercalate, uncons)
@ -24,12 +25,17 @@ import qualified Semantic.Task as Task
import Semantic.Task.Files
import qualified Semantic.Telemetry.Log as Log
import Semantic.Version
import System.Exit (die)
import System.FilePath
import Serializing.Format hiding (Options)
import Text.Read
main :: IO ()
main = customExecParser (prefs showHelpOnEmpty) arguments >>= uncurry Task.runTaskWithOptions
main = do
(options, task) <- customExecParser (prefs showHelpOnEmpty) arguments
res <- Task.withOptions options $ \ config logger statter ->
Task.runTaskWithConfig config { configSHA = Just buildSHA } logger statter task
either (die . displayException) pure res
-- | A parser for the application's command-line arguments.
--

View File

@ -23,7 +23,6 @@ import Semantic.Env
import Semantic.Telemetry
import qualified Semantic.Telemetry.Haystack as Haystack
import qualified Semantic.Telemetry.Stat as Stat
import Semantic.Version
import System.Environment
import System.IO (hIsTerminalDevice, stdout)
import System.Posix.Process
@ -43,6 +42,7 @@ data Config
, configIsTerminal :: Bool -- ^ Whether a terminal is attached (set automaticaly at runtime).
, configLogPrintSource :: Bool -- ^ Whether to print the source reference when logging errors (set automatically at runtime).
, configLogFormatter :: LogFormatter -- ^ Log formatter to use (set automaticaly at runtime).
, configSHA :: Maybe String -- ^ Optional SHA to include in log messages.
, configOptions :: Options -- ^ Options configurable via command line arguments.
}
@ -84,6 +84,7 @@ defaultConfig options@Options{..} = do
, configIsTerminal = isTerminal
, configLogPrintSource = isTerminal
, configLogFormatter = if isTerminal then terminalFormatter else logfmtFormatter
, configSHA = Nothing
, configOptions = options
}
@ -105,8 +106,9 @@ logOptionsFromConfig Config{..} = LogOptions
False -> [ ("app", configAppName)
, ("pid", show configProcessID)
, ("hostname", configHostName)
, ("sha", buildSHA)
] <> [("request_id", x) | x <- toList (optionsRequestID configOptions) ]
, ("sha", fromMaybe "development" configSHA)
]
<> [("request_id", x) | x <- toList (optionsRequestID configOptions) ]
_ -> []

View File

@ -18,7 +18,7 @@ import Semantic.Config (defaultOptions)
import Semantic.Graph
import Semantic.IO
callGraphPythonProject paths = runTaskWithOptions defaultOptions $ do
callGraphPythonProject paths = runTask $ do
let proxy = Proxy @'Language.Python
let lang = Language.Python
blobs <- catMaybes <$> traverse readBlobFromFile (flip File lang <$> paths)