feat: make git revision accessable to nix build
This commit is contained in:
parent
d89d4cfbbc
commit
b37c2e6aec
@ -1,4 +1,4 @@
|
||||
-- SPDX-FileCopyrightText: 2022 Felix Hamann <felix.hamann@campus.lmu.de>,Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Sarah Vaupel <vaupel.sarah@campus.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>,Winnie Ros <winnie.ros@campus.lmu.de>
|
||||
-- SPDX-FileCopyrightText: 2022-2023 Felix Hamann <felix.hamann@campus.lmu.de>, Gregor Kleen <gregor@kleen.consulting>, Sarah Vaupel <sarah.vaupel@ifi.lmu.de>, Steffen Jost <jost@tcs.ifi.lmu.de>, Winnie Ros <winnie.ros@campus.lmu.de>
|
||||
--
|
||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
@ -43,7 +43,7 @@ pickLegalExternalLang = do
|
||||
getVersionR :: Handler TypedContent
|
||||
getVersionR = selectRep $ do
|
||||
provideRep $
|
||||
return ($gitDescribe :: Text)
|
||||
return ($orGitRevisionEnv gitDescribe :: Text)
|
||||
provideRep getInfoR
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ getInfoR = do
|
||||
knownBugs = $(i18nWidgetFile "knownBugs")
|
||||
implementation = $(i18nWidgetFile "implementation")
|
||||
gitInfo :: Text
|
||||
gitInfo = $gitDescribe <> " (" <> $gitCommitDate <> ")"
|
||||
gitInfo = $(orGitRevisionEnv gitDescribeDate)
|
||||
$(widgetFile "versionHistory")
|
||||
|
||||
|
||||
|
||||
@ -1,20 +1,24 @@
|
||||
-- SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>
|
||||
-- SPDX-FileCopyrightText: 2022-2023 Gregor Kleen <gregor@kleen.consulting>
|
||||
--
|
||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
module Handler.Info.TH
|
||||
( glossaryTerms
|
||||
, orGitRevisionEnv, gitDescribeDate
|
||||
) where
|
||||
|
||||
import Import
|
||||
|
||||
import Language.Haskell.TH
|
||||
import Language.Haskell.TH.Lib (stringE)
|
||||
|
||||
import qualified Data.Char as Char
|
||||
|
||||
import qualified Data.Map.Strict as Map
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Development.GitRev
|
||||
|
||||
|
||||
glossaryTerms :: FilePath -> Q Exp
|
||||
glossaryTerms basename = do
|
||||
@ -24,3 +28,9 @@ glossaryTerms basename = do
|
||||
where
|
||||
unPathPiece :: Text -> String
|
||||
unPathPiece = repack . mconcat . map (over _head Char.toUpper) . Text.splitOn "-"
|
||||
|
||||
orGitRevisionEnv :: Q Exp -> Q Exp
|
||||
orGitRevisionEnv cont = maybe cont stringE =<< runIO (lookupEnv "GIT_REVISION")
|
||||
|
||||
gitDescribeDate :: Q Exp
|
||||
gitDescribeDate = [e|$gitDescribe <> " (" <> $gitCommitDate <> ")"|]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user