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
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ pickLegalExternalLang = do
|
|||||||
getVersionR :: Handler TypedContent
|
getVersionR :: Handler TypedContent
|
||||||
getVersionR = selectRep $ do
|
getVersionR = selectRep $ do
|
||||||
provideRep $
|
provideRep $
|
||||||
return ($gitDescribe :: Text)
|
return ($orGitRevisionEnv gitDescribe :: Text)
|
||||||
provideRep getInfoR
|
provideRep getInfoR
|
||||||
|
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ getInfoR = do
|
|||||||
knownBugs = $(i18nWidgetFile "knownBugs")
|
knownBugs = $(i18nWidgetFile "knownBugs")
|
||||||
implementation = $(i18nWidgetFile "implementation")
|
implementation = $(i18nWidgetFile "implementation")
|
||||||
gitInfo :: Text
|
gitInfo :: Text
|
||||||
gitInfo = $gitDescribe <> " (" <> $gitCommitDate <> ")"
|
gitInfo = $(orGitRevisionEnv gitDescribeDate)
|
||||||
$(widgetFile "versionHistory")
|
$(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
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
module Handler.Info.TH
|
module Handler.Info.TH
|
||||||
( glossaryTerms
|
( glossaryTerms
|
||||||
|
, orGitRevisionEnv, gitDescribeDate
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
|
||||||
import Language.Haskell.TH
|
import Language.Haskell.TH
|
||||||
|
import Language.Haskell.TH.Lib (stringE)
|
||||||
|
|
||||||
import qualified Data.Char as Char
|
import qualified Data.Char as Char
|
||||||
|
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
|
|
||||||
|
import Development.GitRev
|
||||||
|
|
||||||
|
|
||||||
glossaryTerms :: FilePath -> Q Exp
|
glossaryTerms :: FilePath -> Q Exp
|
||||||
glossaryTerms basename = do
|
glossaryTerms basename = do
|
||||||
@ -24,3 +28,9 @@ glossaryTerms basename = do
|
|||||||
where
|
where
|
||||||
unPathPiece :: Text -> String
|
unPathPiece :: Text -> String
|
||||||
unPathPiece = repack . mconcat . map (over _head Char.toUpper) . Text.splitOn "-"
|
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 <> ")"|]
|
||||||
|
|||||||
Reference in New Issue
Block a user