Skip to content

Commit 409208f

Browse files
authored
Merge pull request #10693 from geekosaur/static-git-info
fix static builds lacking git info
2 parents 2184732 + 1ce7efb commit 409208f

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

.github/workflows/validate.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,11 @@ jobs:
336336
apk add bash curl sudo jq pkgconfig \
337337
zlib-dev zlib-static binutils-gold curl \
338338
gcc g++ gmp-dev libc-dev libffi-dev make \
339-
musl-dev ncurses-dev perl tar xz
339+
musl-dev ncurses-dev perl tar xz git
340+
341+
# Apparently there's some permissions thing inside vs. outside the container
342+
# that Alpine's git doesn't like. Hack around it.
343+
- run: git config --global --add safe.directory $(pwd)
340344

341345
- uses: actions/checkout@v4
342346

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)