imp: dev builds with uncommitted changes now show + in --version

This commit is contained in:
Simon Michael 2022-09-08 12:17:58 -10:00
parent fb0053c15f
commit 93ce75d756

View File

@ -13,7 +13,7 @@ module Hledger.Cli.Version (
) )
where where
import GitHash (GitInfo, giHash, giCommitDate) import GitHash (GitInfo, giHash, giCommitDate, giDirty)
import System.Info (os, arch) import System.Info (os, arch)
import Data.List (intercalate) import Data.List (intercalate)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
@ -42,7 +42,8 @@ progname = "hledger"
-- --
-- * Program name, OS and architecture are always shown. -- * Program name, OS and architecture are always shown.
-- * The package version is always shown. -- * The package version is always shown.
-- * If there is git info at build time, the latest commit hash and commit date are shown. -- * If there is git info at build time, the latest commit hash and commit date are shown,
-- and if the working copy has uncommitted changes a + sign is appended.
-- * (TODO, requires adding --match support to githash: -- * (TODO, requires adding --match support to githash:
-- If there are tags matching THISPKG-[0-9]*, the latest one is used to calculate patch level -- If there are tags matching THISPKG-[0-9]*, the latest one is used to calculate patch level
-- (number of commits since tag), and if non-zero, it and the branch name are shown.) -- (number of commits since tag), and if non-zero, it and the branch name are shown.)
@ -69,7 +70,7 @@ versionStringWith egitinfo prognam packagever =
case words $ giCommitDate gitinfo of case words $ giCommitDate gitinfo of
-- git log's date format is normally --date=default ("similar to --date=rfc2822") -- git log's date format is normally --date=default ("similar to --date=rfc2822")
_weekday:mon:day:_localtime:year:_offset:_ -> _weekday:mon:day:_localtime:year:_offset:_ ->
intercalate "-" [packagever , hash, date] intercalate "-" $ [packagever, hash, date] ++ ["+" | giDirty gitinfo]
where where
hash = 'g' : take 9 (giHash gitinfo) -- like git describe hash = 'g' : take 9 (giHash gitinfo) -- like git describe
date = concat [year,mm,dd] date = concat [year,mm,dd]