-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Catch exception if git is not installed (#10486)
* Catch exception if git is not installed * fix formatting * change type from IO to m * add maybeReadProcessWithExitCode * use maybeReadProcessWithExitCode * disambiguate P.catch * add TypeApplications pragma * add missing arguments * Add changelog entry * Add test for `cabal init` when `git` is not installed * Remove withSourceCopyDir from test * Remove withSourceCopyDir from test * Remove configure and build from test * Remove assert * Skip test on windows --------- Co-authored-by: noiioiu <[email protected]>
- Loading branch information
Showing
5 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# cabal init |
22 changes: 22 additions & 0 deletions
22
cabal-testsuite/PackageTests/Init/init-without-git.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Test.Cabal.Prelude | ||
import System.Directory | ||
import System.FilePath | ||
import Distribution.Simple.Utils | ||
import Distribution.Verbosity | ||
|
||
-- Test cabal init when git is not installed | ||
main = do | ||
skipIfWindows "Might fail on windows." | ||
tmp <- getTemporaryDirectory | ||
withTempDirectory normal tmp "bin" $ | ||
\bin -> cabalTest $ | ||
do | ||
ghc_path <- programPathM ghcProgram | ||
cabal_path <- programPathM cabalProgram | ||
withSymlink ghc_path (bin </> "ghc") . withSymlink cabal_path (bin </> "cabal") . | ||
withEnv [("PATH", Just bin)] $ do | ||
cwd <- fmap testSourceCopyDir getTestEnv | ||
|
||
void . withDirectory cwd $ do | ||
cabalWithStdin "init" ["-i"] | ||
"2\n\n5\n\n\n2\n\n\n\n\n\n\n\n\n\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
synopsis: Fix a bug that causes `cabal init` to crash if `git` is not installed | ||
packages: cabal-install | ||
prs: #10486 | ||
issues: #10484 #8478 | ||
significance: | ||
|
||
description: { | ||
|
||
- `cabal init` tries to use `git config` to guess the user's name and email. | ||
It no longer crashes if there is no executable named `git` on $PATH. | ||
|
||
} |