on master help sign in
Extend version message to include path and git commit (#306)
commitb78efe36bb013650136b844b014b3522612b8113 authorPepe Iborra <pepeiborra@gmail.com> dateMon 6 Jan 2020, 08:13 (7 years ago) parent64693ed
2 files changed+15−5
exe/Main.hs+14−5 ghcide.cabal+1
exe/Main.hs+14−5
@@ -2,6 +2,7 @@
22-- SPDX-License-Identifier: Apache-2.0
33{-# OPTIONS_GHC -Wno-dodgy-imports #-} -- GHC no longer exports def in GHC 8.6 and above
44{-# LANGUAGE CPP #-} -- To get precise GHC version
5+{-# LANGUAGE TemplateHaskell #-}
56
67module Main(main) where
78
@@ -39,6 +40,7 @@ import System.Environment
3940import System.IO
4041import System.Exit
4142import Paths_ghcide
43+import Development.GitRev
4244import Development.Shake (Action, action)
4345import qualified Data.Set as Set
4446import qualified Data.Map.Strict as Map
@@ -52,9 +54,16 @@ import HIE.Bios
5254getLibdir :: IO FilePath
5355getLibdir = fromMaybe GHC.Paths.libdir <$> lookupEnv "NIX_GHC_LIBDIR"
5456
55−ghcideVersion :: String
56−ghcideVersion = "ghcide version: " <> showVersion version
57− <> " (GHC: " <> VERSION_ghc <> ")"
57+ghcideVersion :: IO String
58+ghcideVersion = do
59+ path <- getExecutablePath
60+ let gitHashSection = case $(gitHash) of
61+ x | x == "UNKNOWN" -> ""
62+ x -> " (GIT hash: " <> x <> ")"
63+ return $ "ghcide version: " <> showVersion version
64+ <> " (GHC: " <> VERSION_ghc
65+ <> ") (PATH: " <> path <> ")"
66+ <> gitHashSection
5867
5968main :: IO ()
6069main = do
@@ -62,8 +71,8 @@ main = do
6271 -- then the language server will not work
6372 Arguments{..} <- getArguments
6473
65− if argsVersion then putStrLn ghcideVersion >> exitSuccess
66− else hPutStrLn stderr {- see WARNING above -} ghcideVersion
74+ if argsVersion then ghcideVersion >>= putStrLn >> exitSuccess
75+ else hPutStrLn stderr {- see WARNING above -} =<< ghcideVersion
6776
6877 -- lock to avoid overlapping output on stdout
6978 lock <- newLock
ghcide.cabal+1
@@ -162,6 +162,7 @@ executable ghcide
162162 filepath,
163163 ghc-paths,
164164 ghc,
165+ gitrev,
165166 haskell-lsp,
166167 hie-bios >= 0.3.2 && < 0.4,
167168 ghcide,