Merge branch 'issue-380'
This commit is contained in:
commit
86a8a32032
@ -82,7 +82,7 @@ data HLSCompileOptions = HLSCompileOptions
|
|||||||
{ targetHLS :: Either Version GitBranch
|
{ targetHLS :: Either Version GitBranch
|
||||||
, jobs :: Maybe Int
|
, jobs :: Maybe Int
|
||||||
, setCompile :: Bool
|
, setCompile :: Bool
|
||||||
, ovewrwiteVer :: Maybe Version
|
, ovewrwiteVer :: Either Bool Version
|
||||||
, isolateDir :: Maybe FilePath
|
, isolateDir :: Maybe FilePath
|
||||||
, cabalProject :: Maybe (Either FilePath URI)
|
, cabalProject :: Maybe (Either FilePath URI)
|
||||||
, cabalProjectLocal :: Maybe URI
|
, cabalProjectLocal :: Maybe URI
|
||||||
@ -145,14 +145,16 @@ Examples:
|
|||||||
|
|
||||||
compileHLSFooter = [s|Discussion:
|
compileHLSFooter = [s|Discussion:
|
||||||
Compiles and installs the specified HLS version.
|
Compiles and installs the specified HLS version.
|
||||||
The last argument is a list of GHC versions to compile for.
|
The --ghc arguments are necessary to specify which GHC version to build for/against.
|
||||||
These need to be available in PATH prior to compilation.
|
These need to be available in PATH prior to compilation.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
# compile 1.4.0 for ghc 8.10.5 and 8.10.7
|
# compile 1.7.0.0 for ghc 8.10.5 and 8.10.7, passing '--allow-newer' to cabal
|
||||||
ghcup compile hls -v 1.4.0 -j 12 --ghc 8.10.5 --ghc 8.10.7
|
ghcup compile hls -v 1.7.0.0 -j 12 --ghc 8.10.5 --ghc 8.10.7 -- --allow-newer
|
||||||
# compile from master for ghc 8.10.7, linking everything dynamically
|
# compile from master for ghc 9.2.3 and use 'git describe' to name the binary
|
||||||
ghcup compile hls -g master -j 12 --ghc 8.10.7 -- --ghc-options='-dynamic'|]
|
ghcup compile hls -g master --git-describe-version --ghc 9.2.3
|
||||||
|
# compile a specific commit for ghc 9.2.3 and set a specifc version for the binary name
|
||||||
|
ghcup compile hls -g a32db0b -o 1.7.0.0-p1 --ghc 9.2.3|]
|
||||||
|
|
||||||
|
|
||||||
ghcCompileOpts :: Parser GHCCompileOptions
|
ghcCompileOpts :: Parser GHCCompileOptions
|
||||||
@ -280,7 +282,7 @@ hlsCompileOpts =
|
|||||||
(Right <$> (GitBranch <$> option
|
(Right <$> (GitBranch <$> option
|
||||||
str
|
str
|
||||||
(short 'g' <> long "git-ref" <> metavar "GIT_REFERENCE" <> help
|
(short 'g' <> long "git-ref" <> metavar "GIT_REFERENCE" <> help
|
||||||
"The git commit/branch/ref to build from"
|
"The git commit/branch/ref to build from (accepts anything 'git checkout' accepts)"
|
||||||
) <*>
|
) <*>
|
||||||
optional (option str (short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to HLS upstream)"
|
optional (option str (short 'r' <> long "repository" <> metavar "GIT_REPOSITORY" <> help "The git repository to build from (defaults to HLS upstream)"
|
||||||
<> completer (gitFileUri ["https://github.com/haskell/haskell-language-server.git"])
|
<> completer (gitFileUri ["https://github.com/haskell/haskell-language-server.git"])
|
||||||
@ -295,8 +297,9 @@ hlsCompileOpts =
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
<*> fmap (fromMaybe True) (invertableSwitch "set" Nothing True (help "Don't set as active version after install"))
|
<*> fmap (fromMaybe True) (invertableSwitch "set" Nothing True (help "Don't set as active version after install"))
|
||||||
<*> optional
|
<*>
|
||||||
(option
|
(
|
||||||
|
(Right <$> option
|
||||||
(eitherReader
|
(eitherReader
|
||||||
(first (const "Not a valid version") . version . T.pack)
|
(first (const "Not a valid version") . version . T.pack)
|
||||||
)
|
)
|
||||||
@ -305,6 +308,14 @@ hlsCompileOpts =
|
|||||||
<> (completer $ versionCompleter Nothing HLS)
|
<> (completer $ versionCompleter Nothing HLS)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
<|>
|
||||||
|
(Left <$> (switch
|
||||||
|
(long "git-describe-version"
|
||||||
|
<> help "Use the output of 'git describe' (if building from git) as the VERSION component of the installed binary."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
<*> optional
|
<*> optional
|
||||||
(option
|
(option
|
||||||
(eitherReader isolateParser)
|
(eitherReader isolateParser)
|
||||||
|
@ -340,7 +340,7 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
|
|||||||
(GHC, ver) = cmp' GHC (Just $ ToolVersion (mkTVer over)) ver
|
(GHC, ver) = cmp' GHC (Just $ ToolVersion (mkTVer over)) ver
|
||||||
alreadyInstalling (Compile (CompileGHC GHCCompileOptions{ targetGhc = Left tver }))
|
alreadyInstalling (Compile (CompileGHC GHCCompileOptions{ targetGhc = Left tver }))
|
||||||
(GHC, ver) = cmp' GHC (Just $ ToolVersion (mkTVer tver)) ver
|
(GHC, ver) = cmp' GHC (Just $ ToolVersion (mkTVer tver)) ver
|
||||||
alreadyInstalling (Compile (CompileHLS HLSCompileOptions{ ovewrwiteVer = Just over }))
|
alreadyInstalling (Compile (CompileHLS HLSCompileOptions{ ovewrwiteVer = Right over }))
|
||||||
(HLS, ver) = cmp' HLS (Just $ ToolVersion (mkTVer over)) ver
|
(HLS, ver) = cmp' HLS (Just $ ToolVersion (mkTVer over)) ver
|
||||||
alreadyInstalling (Compile (CompileHLS HLSCompileOptions{ targetHLS = Left tver }))
|
alreadyInstalling (Compile (CompileHLS HLSCompileOptions{ targetHLS = Left tver }))
|
||||||
(HLS, ver) = cmp' HLS (Just $ ToolVersion (mkTVer tver)) ver
|
(HLS, ver) = cmp' HLS (Just $ ToolVersion (mkTVer tver)) ver
|
||||||
|
@ -164,8 +164,10 @@ library
|
|||||||
cpp-options: -DIS_WINDOWS
|
cpp-options: -DIS_WINDOWS
|
||||||
other-modules:
|
other-modules:
|
||||||
GHCup.Prelude.File.Windows
|
GHCup.Prelude.File.Windows
|
||||||
GHCup.Prelude.Process.Windows
|
|
||||||
GHCup.Prelude.Windows
|
GHCup.Prelude.Windows
|
||||||
|
-- GHCup.OptParse.Run uses this
|
||||||
|
exposed-modules:
|
||||||
|
GHCup.Prelude.Process.Windows
|
||||||
|
|
||||||
build-depends:
|
build-depends:
|
||||||
, bzlib
|
, bzlib
|
||||||
|
@ -566,8 +566,11 @@ rmGHCVer ver = do
|
|||||||
lift $ recycleFile f
|
lift $ recycleFile f
|
||||||
when (not (null survivors)) $ throwE $ UninstallFailed dir survivors
|
when (not (null survivors)) $ throwE $ UninstallFailed dir survivors
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
|
isDir <- liftIO $ doesDirectoryExist dir
|
||||||
|
isSyml <- liftIO $ handleIO (\_ -> pure False) $ pathIsSymbolicLink dir
|
||||||
|
when (isDir && not isSyml) $ do
|
||||||
lift $ logInfo $ "Removing legacy directory recursively: " <> T.pack dir
|
lift $ logInfo $ "Removing legacy directory recursively: " <> T.pack dir
|
||||||
lift $ recyclePathForcibly dir'
|
recyclePathForcibly dir'
|
||||||
|
|
||||||
v' <-
|
v' <-
|
||||||
handle
|
handle
|
||||||
@ -681,28 +684,53 @@ compileGHC targetGhc ov bstrap jobs mbuildConfig patches aargs buildFlavour hadr
|
|||||||
, "origin"
|
, "origin"
|
||||||
, fromString rep ]
|
, fromString rep ]
|
||||||
|
|
||||||
let fetch_args =
|
-- figure out if we can do a shallow clone
|
||||||
[ "fetch"
|
remoteBranches <- catchE @ProcessError @'[PatchFailed, ProcessError, NotFoundInPATH, DigestError, DownloadFailed, GPGError] @'[PatchFailed, NotFoundInPATH, DigestError, DownloadFailed, GPGError] (\(_ :: ProcessError) -> pure [])
|
||||||
, "--depth"
|
$ fmap processBranches $ gitOut ["ls-remote", "--heads", "origin"] (fromGHCupPath tmpUnpack)
|
||||||
, "1"
|
let shallow_clone
|
||||||
, "--quiet"
|
| isCommitHash ref = True
|
||||||
, "origin"
|
| fromString ref `elem` remoteBranches = True
|
||||||
, fromString ref ]
|
| otherwise = False
|
||||||
|
lift $ logDebug $ "Shallow clone: " <> T.pack (show shallow_clone)
|
||||||
|
|
||||||
|
-- fetch
|
||||||
|
let fetch_args
|
||||||
|
| shallow_clone = ["fetch", "--depth", "1", "--quiet", "origin", fromString ref]
|
||||||
|
| otherwise = ["fetch", "--tags", "--quiet", "origin" ]
|
||||||
lEM $ git fetch_args
|
lEM $ git fetch_args
|
||||||
|
|
||||||
lEM $ git [ "checkout", "FETCH_HEAD" ]
|
-- initial checkout
|
||||||
|
lEM $ git [ "checkout", fromString ref ]
|
||||||
|
|
||||||
|
-- gather some info
|
||||||
|
git_describe <- if shallow_clone
|
||||||
|
then pure Nothing
|
||||||
|
else fmap Just $ liftE $ gitOut ["describe", "--tags"] (fromGHCupPath tmpUnpack)
|
||||||
|
chash <- liftE $ gitOut ["rev-parse", "HEAD" ] (fromGHCupPath tmpUnpack)
|
||||||
|
|
||||||
|
-- clone submodules
|
||||||
lEM $ git [ "submodule", "update", "--init", "--depth", "1" ]
|
lEM $ git [ "submodule", "update", "--init", "--depth", "1" ]
|
||||||
|
|
||||||
|
-- apply patches
|
||||||
liftE $ applyAnyPatch patches (fromGHCupPath tmpUnpack)
|
liftE $ applyAnyPatch patches (fromGHCupPath tmpUnpack)
|
||||||
|
|
||||||
|
-- bootstrap
|
||||||
lEM $ execWithGhcEnv "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
|
lEM $ execWithGhcEnv "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
|
||||||
lEM $ execWithGhcEnv "sh" ["./configure"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
|
lEM $ execWithGhcEnv "sh" ["./configure"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
|
||||||
CapturedProcess {..} <- lift $ makeOut
|
CapturedProcess {..} <- lift $ makeOut
|
||||||
["show!", "--quiet", "VALUE=ProjectVersion" ] (Just $ fromGHCupPath tmpUnpack)
|
["show!", "--quiet", "VALUE=ProjectVersion" ] (Just $ fromGHCupPath tmpUnpack)
|
||||||
case _exitCode of
|
tver <- case _exitCode of
|
||||||
ExitSuccess -> throwEither . MP.parse ghcProjectVersion "" . decUTF8Safe' $ _stdOut
|
ExitSuccess -> throwEither . MP.parse ghcProjectVersion "" . T.pack . stripNewlineEnd . T.unpack . decUTF8Safe' $ _stdOut
|
||||||
ExitFailure c -> fail ("Could not figure out GHC project version. Exit code was: " <> show c <> ". Error was: " <> T.unpack (decUTF8Safe' _stdErr))
|
ExitFailure c -> fail ("Could not figure out GHC project version. Exit code was: " <> show c <> ". Error was: " <> T.unpack (decUTF8Safe' _stdErr))
|
||||||
|
|
||||||
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
|
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
|
||||||
lift $ logInfo $ "Git version " <> T.pack ref <> " corresponds to GHC version " <> prettyVer tver
|
lift $ logInfo $ "Examining git ref " <> T.pack ref <> "\n " <>
|
||||||
|
"GHC version (from Makefile): " <> prettyVer tver <>
|
||||||
|
(if not shallow_clone then "\n " <> "'git describe' output: " <> fromJust git_describe else mempty) <>
|
||||||
|
(if isCommitHash ref then mempty else "\n " <> "commit hash: " <> chash)
|
||||||
|
liftIO $ threadDelay 5000000 -- give the user a sec to intervene
|
||||||
|
|
||||||
|
pure tver
|
||||||
|
|
||||||
pure (tmpUnpack, tmpUnpack, GHCTargetVersion Nothing tver)
|
pure (tmpUnpack, tmpUnpack, GHCTargetVersion Nothing tver)
|
||||||
-- the version that's installed may differ from the
|
-- the version that's installed may differ from the
|
||||||
|
@ -327,7 +327,7 @@ compileHLS :: ( MonadMask m
|
|||||||
=> Either Version GitBranch
|
=> Either Version GitBranch
|
||||||
-> [Version]
|
-> [Version]
|
||||||
-> Maybe Int
|
-> Maybe Int
|
||||||
-> Maybe Version
|
-> Either Bool Version
|
||||||
-> InstallDir
|
-> InstallDir
|
||||||
-> Maybe (Either FilePath URI)
|
-> Maybe (Either FilePath URI)
|
||||||
-> Maybe URI
|
-> Maybe URI
|
||||||
@ -349,7 +349,7 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
Dirs { .. } <- lift getDirs
|
Dirs { .. } <- lift getDirs
|
||||||
|
|
||||||
|
|
||||||
(workdir, tver) <- case targetHLS of
|
(workdir, tver, git_describe) <- case targetHLS of
|
||||||
-- unpack from version tarball
|
-- unpack from version tarball
|
||||||
Left tver -> do
|
Left tver -> do
|
||||||
lift $ logDebug $ "Requested to compile: " <> prettyVer tver
|
lift $ logDebug $ "Requested to compile: " <> prettyVer tver
|
||||||
@ -369,13 +369,13 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
(liftE . intoSubdir tmpUnpack)
|
(liftE . intoSubdir tmpUnpack)
|
||||||
(view dlSubdir dlInfo)
|
(view dlSubdir dlInfo)
|
||||||
|
|
||||||
pure (workdir, tver)
|
pure (workdir, tver, Nothing)
|
||||||
|
|
||||||
-- clone from git
|
-- clone from git
|
||||||
Right GitBranch{..} -> do
|
Right GitBranch{..} -> do
|
||||||
tmpUnpack <- lift mkGhcupTmpDir
|
tmpUnpack <- lift mkGhcupTmpDir
|
||||||
let git args = execLogged "git" ("--no-pager":args) (Just $ fromGHCupPath tmpUnpack) "git" Nothing
|
let git args = execLogged "git" ("--no-pager":args) (Just $ fromGHCupPath tmpUnpack) "git" Nothing
|
||||||
tver <- reThrowAll @_ @'[ProcessError] DownloadFailed $ do
|
reThrowAll @_ @'[ProcessError] DownloadFailed $ do
|
||||||
let rep = fromMaybe "https://github.com/haskell/haskell-language-server.git" repo
|
let rep = fromMaybe "https://github.com/haskell/haskell-language-server.git" repo
|
||||||
lift $ logInfo $ "Fetching git repo " <> T.pack rep <> " at ref " <> T.pack ref <> " (this may take a while)"
|
lift $ logInfo $ "Fetching git repo " <> T.pack rep <> " at ref " <> T.pack ref <> " (this may take a while)"
|
||||||
lEM $ git [ "init" ]
|
lEM $ git [ "init" ]
|
||||||
@ -384,18 +384,34 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
, "origin"
|
, "origin"
|
||||||
, fromString rep ]
|
, fromString rep ]
|
||||||
|
|
||||||
let fetch_args =
|
-- figure out if we can do a shallow clone
|
||||||
[ "fetch"
|
remoteBranches <- catchE @ProcessError @'[ProcessError] @'[] (\_ -> pure [])
|
||||||
, "--depth"
|
$ fmap processBranches $ gitOut ["ls-remote", "--heads", "origin"] (fromGHCupPath tmpUnpack)
|
||||||
, "1"
|
let shallow_clone
|
||||||
, "--quiet"
|
| gitDescribeRequested = False
|
||||||
, "origin"
|
| isCommitHash ref = True
|
||||||
, fromString ref ]
|
| fromString ref `elem` remoteBranches = True
|
||||||
|
| otherwise = False
|
||||||
|
|
||||||
|
lift $ logDebug $ "Shallow clone: " <> T.pack (show shallow_clone)
|
||||||
|
|
||||||
|
-- fetch
|
||||||
|
let fetch_args
|
||||||
|
| shallow_clone = ["fetch", "--depth", "1", "--quiet", "origin", fromString ref]
|
||||||
|
| otherwise = ["fetch", "--tags", "--quiet", "origin" ]
|
||||||
lEM $ git fetch_args
|
lEM $ git fetch_args
|
||||||
|
|
||||||
lEM $ git [ "checkout", "FETCH_HEAD" ]
|
-- checkout
|
||||||
(Just gpd) <- parseGenericPackageDescriptionMaybe <$> liftIO (B.readFile (fromGHCupPath tmpUnpack </> "haskell-language-server.cabal"))
|
lEM $ git [ "checkout", fromString ref ]
|
||||||
pure . (\c -> Version Nothing c [] Nothing)
|
|
||||||
|
-- gather some info
|
||||||
|
git_describe <- if shallow_clone
|
||||||
|
then pure Nothing
|
||||||
|
else fmap Just $ gitOut ["describe", "--tags"] (fromGHCupPath tmpUnpack)
|
||||||
|
chash <- gitOut ["rev-parse", "HEAD" ] (fromGHCupPath tmpUnpack)
|
||||||
|
(Just gpd) <- parseGenericPackageDescriptionMaybe
|
||||||
|
<$> liftIO (B.readFile (fromGHCupPath tmpUnpack </> "haskell-language-server.cabal"))
|
||||||
|
let tver = (\c -> Version Nothing c [] Nothing)
|
||||||
. NE.fromList . fmap (NE.fromList . (:[]) . digits . fromIntegral)
|
. NE.fromList . fmap (NE.fromList . (:[]) . digits . fromIntegral)
|
||||||
. versionNumbers
|
. versionNumbers
|
||||||
. pkgVersion
|
. pkgVersion
|
||||||
@ -404,13 +420,25 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
$ gpd
|
$ gpd
|
||||||
|
|
||||||
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
|
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
|
||||||
lift $ logInfo $ "Git version " <> T.pack ref <> " corresponds to HLS version " <> prettyVer tver
|
lift $ logInfo $ "Examining git ref " <> T.pack ref <> "\n " <>
|
||||||
|
"HLS version (from cabal file): " <> prettyVer tver <>
|
||||||
|
(if not shallow_clone then "\n " <> "'git describe' output: " <> fromJust git_describe else mempty) <>
|
||||||
|
(if isCommitHash ref then mempty else "\n " <> "commit hash: " <> chash)
|
||||||
|
|
||||||
pure (tmpUnpack, tver)
|
pure (tmpUnpack, tver, git_describe)
|
||||||
|
|
||||||
-- the version that's installed may differ from the
|
-- the version that's installed may differ from the
|
||||||
-- compiled version, so the user can overwrite it
|
-- compiled version, so the user can overwrite it
|
||||||
let installVer = fromMaybe tver ov
|
installVer <- case ov of
|
||||||
|
Left True -> case git_describe of
|
||||||
|
-- git describe
|
||||||
|
Just h -> either (fail . displayException) pure . version $ h
|
||||||
|
-- git describe, but not building from git, lol
|
||||||
|
Nothing -> pure tver
|
||||||
|
-- default: use detected version
|
||||||
|
Left False -> pure tver
|
||||||
|
-- overwrite version with users value
|
||||||
|
Right v -> pure v
|
||||||
|
|
||||||
liftE $ runBuildAction
|
liftE $ runBuildAction
|
||||||
workdir
|
workdir
|
||||||
@ -464,7 +492,7 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
pure ghcInstallDir
|
pure ghcInstallDir
|
||||||
|
|
||||||
forM_ artifacts $ \artifact -> do
|
forM_ artifacts $ \artifact -> do
|
||||||
logInfo $ T.pack (show artifact)
|
logDebug $ T.pack (show artifact)
|
||||||
liftIO $ renameFile (artifact </> "haskell-language-server" <.> exeExt)
|
liftIO $ renameFile (artifact </> "haskell-language-server" <.> exeExt)
|
||||||
(tmpInstallDir </> "haskell-language-server-" <> takeFileName artifact <.> exeExt)
|
(tmpInstallDir </> "haskell-language-server-" <> takeFileName artifact <.> exeExt)
|
||||||
liftIO $ renameFile (artifact </> "haskell-language-server-wrapper" <.> exeExt)
|
liftIO $ renameFile (artifact </> "haskell-language-server-wrapper" <.> exeExt)
|
||||||
@ -479,6 +507,10 @@ compileHLS targetHLS ghcs jobs ov installDir cabalProject cabalProjectLocal patc
|
|||||||
)
|
)
|
||||||
|
|
||||||
pure installVer
|
pure installVer
|
||||||
|
where
|
||||||
|
gitDescribeRequested = case ov of
|
||||||
|
Left b -> b
|
||||||
|
_ -> False
|
||||||
|
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
@ -614,6 +646,9 @@ rmHLSVer ver = do
|
|||||||
lift $ recycleFile f
|
lift $ recycleFile f
|
||||||
when (not (null survivors)) $ throwE $ UninstallFailed hlsDir survivors
|
when (not (null survivors)) $ throwE $ UninstallFailed hlsDir survivors
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
|
isDir <- liftIO $ doesDirectoryExist hlsDir
|
||||||
|
isSyml <- liftIO $ handleIO (\_ -> pure False) $ pathIsSymbolicLink hlsDir
|
||||||
|
when (isDir && not isSyml) $ do
|
||||||
lift $ logInfo $ "Removing legacy directory recursively: " <> T.pack hlsDir
|
lift $ logInfo $ "Removing legacy directory recursively: " <> T.pack hlsDir
|
||||||
recyclePathForcibly hlsDir'
|
recyclePathForcibly hlsDir'
|
||||||
|
|
||||||
|
@ -211,8 +211,8 @@ exec exe args chdir env = do
|
|||||||
let paths = ["PATH", "Path"]
|
let paths = ["PATH", "Path"]
|
||||||
curPaths = (\x -> maybe [] splitSearchPath (Map.lookup x cEnv)) =<< paths
|
curPaths = (\x -> maybe [] splitSearchPath (Map.lookup x cEnv)) =<< paths
|
||||||
newPath = intercalate [searchPathSeparator] curPaths
|
newPath = intercalate [searchPathSeparator] curPaths
|
||||||
setEnv "PATH" ""
|
liftIO $ setEnv "PATH" ""
|
||||||
setEnv "Path" newPath
|
liftIO $ setEnv "Path" newPath
|
||||||
cp <- createProcessWithMingwPath ((proc exe args) { cwd = chdir, env = env })
|
cp <- createProcessWithMingwPath ((proc exe args) { cwd = chdir, env = env })
|
||||||
exit_code <- liftIO $ withCreateProcess cp $ \_ _ _ p -> waitForProcess p
|
exit_code <- liftIO $ withCreateProcess cp $ \_ _ _ p -> waitForProcess p
|
||||||
pure $ toProcessError exe args exit_code
|
pure $ toProcessError exe args exit_code
|
||||||
@ -230,8 +230,8 @@ execNoMinGW exe args chdir env = do
|
|||||||
let paths = ["PATH", "Path"]
|
let paths = ["PATH", "Path"]
|
||||||
curPaths = (\x -> maybe [] splitSearchPath (Map.lookup x cEnv)) =<< paths
|
curPaths = (\x -> maybe [] splitSearchPath (Map.lookup x cEnv)) =<< paths
|
||||||
newPath = intercalate [searchPathSeparator] curPaths
|
newPath = intercalate [searchPathSeparator] curPaths
|
||||||
setEnv "PATH" ""
|
liftIO $ setEnv "PATH" ""
|
||||||
setEnv "Path" newPath
|
liftIO $ setEnv "Path" newPath
|
||||||
let cp = (proc exe args) { cwd = chdir, env = env }
|
let cp = (proc exe args) { cwd = chdir, env = env }
|
||||||
exit_code <- liftIO $ withCreateProcess cp $ \_ _ _ p -> waitForProcess p
|
exit_code <- liftIO $ withCreateProcess cp $ \_ _ _ p -> waitForProcess p
|
||||||
pure $ toProcessError exe args exit_code
|
pure $ toProcessError exe args exit_code
|
||||||
|
@ -61,6 +61,7 @@ import Control.Monad.Reader
|
|||||||
import Control.Monad.Trans.Resource
|
import Control.Monad.Trans.Resource
|
||||||
hiding ( throwM )
|
hiding ( throwM )
|
||||||
import Control.Monad.IO.Unlift ( MonadUnliftIO( withRunInIO ) )
|
import Control.Monad.IO.Unlift ( MonadUnliftIO( withRunInIO ) )
|
||||||
|
import Data.Char ( isHexDigit )
|
||||||
import Data.Bifunctor ( first )
|
import Data.Bifunctor ( first )
|
||||||
import Data.ByteString ( ByteString )
|
import Data.ByteString ( ByteString )
|
||||||
import Data.Either
|
import Data.Either
|
||||||
@ -1275,3 +1276,35 @@ warnAboutHlsCompatibility = do
|
|||||||
T.pack (prettyShow supportedGHC)
|
T.pack (prettyShow supportedGHC)
|
||||||
|
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-----------
|
||||||
|
--[ Git ]--
|
||||||
|
-----------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
isCommitHash :: String -> Bool
|
||||||
|
isCommitHash str' = let hex = all isHexDigit str'
|
||||||
|
len = length str'
|
||||||
|
in hex && len == 40
|
||||||
|
|
||||||
|
|
||||||
|
gitOut :: (MonadReader env m, HasLog env, MonadIO m) => [String] -> FilePath -> Excepts '[ProcessError] m T.Text
|
||||||
|
gitOut args dir = do
|
||||||
|
CapturedProcess {..} <- lift $ executeOut "git" args (Just dir)
|
||||||
|
case _exitCode of
|
||||||
|
ExitSuccess -> pure $ T.pack $ stripNewlineEnd $ T.unpack $ decUTF8Safe' _stdOut
|
||||||
|
ExitFailure c -> do
|
||||||
|
let pe = NonZeroExit c "git" args
|
||||||
|
lift $ logDebug $ T.pack (prettyShow pe)
|
||||||
|
throwE pe
|
||||||
|
|
||||||
|
processBranches :: T.Text -> [String]
|
||||||
|
processBranches str' = let lines' = lines (T.unpack str')
|
||||||
|
words' = fmap words lines'
|
||||||
|
refs = catMaybes $ fmap (`atMay` 1) words'
|
||||||
|
branches = catMaybes $ fmap (stripPrefix "refs/heads/") $ filter (isPrefixOf "refs/heads/") refs
|
||||||
|
in branches
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user