Skip to content

Commit 1ce7efb

Browse files
geekosaurMikolaj
authored andcommitted
degrade gracefully if no git information available
1 parent 337ffcf commit 1ce7efb

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

Cabal/src/Distribution/Simple/Utils.hs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,18 @@ cabalVersion = mkVersion [3,0] --used when bootstrapping
311311

312312
-- |
313313
-- `Cabal` Git information. Only filled in if built in a Git tree in
314-
-- developmnent mode and Template Haskell is available.
314+
-- development mode and Template Haskell is available.
315315
cabalGitInfo :: String
316316
#ifdef GIT_REV
317-
cabalGitInfo = concat [ "(commit "
318-
, giHash'
319-
, branchInfo
320-
, ", "
321-
, either (const "") giCommitDate gi'
322-
, ")"
323-
]
317+
cabalGitInfo = if giHash' == ""
318+
then ""
319+
else concat [ "(commit "
320+
, giHash'
321+
, branchInfo
322+
, ", "
323+
, either (const "") giCommitDate gi'
324+
, ")"
325+
]
324326
where
325327
gi' = $$tGitInfoCwdTry
326328
giHash' = take 7 . either (const "") giHash $ gi'

cabal-install/src/Distribution/Client/Version.hs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ cabalInstallVersion = mkVersion' PackageInfo.version
3333
-- developmnent mode and Template Haskell is available.
3434
cabalInstallGitInfo :: String
3535
#ifdef GIT_REV
36-
cabalInstallGitInfo = concat [ "(commit "
37-
, giHash'
38-
, branchInfo
39-
, ", "
40-
, either (const "") giCommitDate gi'
41-
, ")"
42-
]
36+
cabalInstallGitInfo = if giHash' == ""
37+
then ""
38+
else concat [ "(commit "
39+
, giHash'
40+
, branchInfo
41+
, ", "
42+
, either (const "") giCommitDate gi'
43+
, ")"
44+
]
4345
where
4446
gi' = $$tGitInfoCwdTry
4547
giHash' = take 7 . either (const "") giHash $ gi'

0 commit comments

Comments
 (0)