mirror of
https://github.com/github/semantic.git
synced 2025-01-05 05:58:34 +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:
commit
a0643b725a
@ -6,6 +6,7 @@ module Semantic.CLI
|
|||||||
, Parse.runParse
|
, Parse.runParse
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Control.Exception as Exc (displayException)
|
||||||
import Data.File
|
import Data.File
|
||||||
import Data.Language (ensureLanguage, languageForFilePath)
|
import Data.Language (ensureLanguage, languageForFilePath)
|
||||||
import Data.List (intercalate, uncons)
|
import Data.List (intercalate, uncons)
|
||||||
@ -24,12 +25,17 @@ import qualified Semantic.Task as Task
|
|||||||
import Semantic.Task.Files
|
import Semantic.Task.Files
|
||||||
import qualified Semantic.Telemetry.Log as Log
|
import qualified Semantic.Telemetry.Log as Log
|
||||||
import Semantic.Version
|
import Semantic.Version
|
||||||
|
import System.Exit (die)
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Serializing.Format hiding (Options)
|
import Serializing.Format hiding (Options)
|
||||||
import Text.Read
|
import Text.Read
|
||||||
|
|
||||||
main :: IO ()
|
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.
|
-- | A parser for the application's command-line arguments.
|
||||||
--
|
--
|
||||||
|
@ -23,7 +23,6 @@ import Semantic.Env
|
|||||||
import Semantic.Telemetry
|
import Semantic.Telemetry
|
||||||
import qualified Semantic.Telemetry.Haystack as Haystack
|
import qualified Semantic.Telemetry.Haystack as Haystack
|
||||||
import qualified Semantic.Telemetry.Stat as Stat
|
import qualified Semantic.Telemetry.Stat as Stat
|
||||||
import Semantic.Version
|
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import System.IO (hIsTerminalDevice, stdout)
|
import System.IO (hIsTerminalDevice, stdout)
|
||||||
import System.Posix.Process
|
import System.Posix.Process
|
||||||
@ -43,6 +42,7 @@ data Config
|
|||||||
, configIsTerminal :: Bool -- ^ Whether a terminal is attached (set automaticaly at runtime).
|
, 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).
|
, 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).
|
, 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.
|
, configOptions :: Options -- ^ Options configurable via command line arguments.
|
||||||
}
|
}
|
||||||
@ -84,6 +84,7 @@ defaultConfig options@Options{..} = do
|
|||||||
, configIsTerminal = isTerminal
|
, configIsTerminal = isTerminal
|
||||||
, configLogPrintSource = isTerminal
|
, configLogPrintSource = isTerminal
|
||||||
, configLogFormatter = if isTerminal then terminalFormatter else logfmtFormatter
|
, configLogFormatter = if isTerminal then terminalFormatter else logfmtFormatter
|
||||||
|
, configSHA = Nothing
|
||||||
|
|
||||||
, configOptions = options
|
, configOptions = options
|
||||||
}
|
}
|
||||||
@ -105,8 +106,9 @@ logOptionsFromConfig Config{..} = LogOptions
|
|||||||
False -> [ ("app", configAppName)
|
False -> [ ("app", configAppName)
|
||||||
, ("pid", show configProcessID)
|
, ("pid", show configProcessID)
|
||||||
, ("hostname", configHostName)
|
, ("hostname", configHostName)
|
||||||
, ("sha", buildSHA)
|
, ("sha", fromMaybe "development" configSHA)
|
||||||
] <> [("request_id", x) | x <- toList (optionsRequestID configOptions) ]
|
]
|
||||||
|
<> [("request_id", x) | x <- toList (optionsRequestID configOptions) ]
|
||||||
_ -> []
|
_ -> []
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import Semantic.Config (defaultOptions)
|
|||||||
import Semantic.Graph
|
import Semantic.Graph
|
||||||
import Semantic.IO
|
import Semantic.IO
|
||||||
|
|
||||||
callGraphPythonProject paths = runTaskWithOptions defaultOptions $ do
|
callGraphPythonProject paths = runTask $ do
|
||||||
let proxy = Proxy @'Language.Python
|
let proxy = Proxy @'Language.Python
|
||||||
let lang = Language.Python
|
let lang = Language.Python
|
||||||
blobs <- catMaybes <$> traverse readBlobFromFile (flip File lang <$> paths)
|
blobs <- catMaybes <$> traverse readBlobFromFile (flip File lang <$> paths)
|
||||||
|
Loading…
Reference in New Issue
Block a user