diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index daa0811440d..eee95cba005 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -336,7 +336,11 @@ jobs: apk add bash curl sudo jq pkgconfig \ zlib-dev zlib-static binutils-gold curl \ gcc g++ gmp-dev libc-dev libffi-dev make \ - musl-dev ncurses-dev perl tar xz + musl-dev ncurses-dev perl tar xz git + + # Apparently there's some permissions thing inside vs. outside the container + # that Alpine's git doesn't like. Hack around it. + - run: git config --global --add safe.directory $(pwd) - uses: actions/checkout@v4 diff --git a/Cabal/src/Distribution/Simple/Utils.hs b/Cabal/src/Distribution/Simple/Utils.hs index bdbb72435a3..81763cca8fd 100644 --- a/Cabal/src/Distribution/Simple/Utils.hs +++ b/Cabal/src/Distribution/Simple/Utils.hs @@ -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' diff --git a/cabal-install/src/Distribution/Client/Version.hs b/cabal-install/src/Distribution/Client/Version.hs index e50f4231090..14a3c166f63 100644 --- a/cabal-install/src/Distribution/Client/Version.hs +++ b/cabal-install/src/Distribution/Client/Version.hs @@ -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'