Skip to content

Commit

Permalink
degrade gracefully if no git information available
Browse files Browse the repository at this point in the history
  • Loading branch information
geekosaur committed Dec 31, 2024
1 parent 4c8ca38 commit 7ceac05
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
18 changes: 10 additions & 8 deletions Cabal/src/Distribution/Simple/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,18 @@ cabalVersion = mkVersion [3,0] --used when bootstrapping

-- |
-- `Cabal` Git information. Only filled in if built in a Git tree in
-- developmnent mode and Template Haskell is available.
-- development mode and Template Haskell is available.
cabalGitInfo :: String
#ifdef GIT_REV
cabalGitInfo = concat [ "(commit "
, giHash'
, branchInfo
, ", "
, either (const "") giCommitDate gi'
, ")"
]
cabalGitInfo = if giHash' == ""
then ""
else concat [ "(commit "
, giHash'
, branchInfo
, ", "
, either (const "") giCommitDate gi'
, ")"
]
where
gi' = $$tGitInfoCwdTry
giHash' = take 7 . either (const "") giHash $ gi'
Expand Down
16 changes: 9 additions & 7 deletions cabal-install/src/Distribution/Client/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ cabalInstallVersion = mkVersion' PackageInfo.version
-- developmnent mode and Template Haskell is available.
cabalInstallGitInfo :: String
#ifdef GIT_REV
cabalInstallGitInfo = concat [ "(commit "
, giHash'
, branchInfo
, ", "
, either (const "") giCommitDate gi'
, ")"
]
cabalInstallGitInfo = if giHash' == ""
then ""
else concat [ "(commit "
, giHash'
, branchInfo
, ", "
, either (const "") giCommitDate gi'
, ")"
]
where
gi' = $$tGitInfoCwdTry
giHash' = take 7 . either (const "") giHash $ gi'
Expand Down

0 comments on commit 7ceac05

Please sign in to comment.