From d9400635bcb28674c8510d71aa6eed94194bf669 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 7 Nov 2023 14:53:26 +0100 Subject: add issue marker as internal tag @type --- app/Issue/Tag.hs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'app/Issue/Tag.hs') diff --git a/app/Issue/Tag.hs b/app/Issue/Tag.hs index c2358a8..90c7520 100644 --- a/app/Issue/Tag.hs +++ b/app/Issue/Tag.hs @@ -4,11 +4,12 @@ module Issue.Tag internalTags, tagKey, tagValue, + tagValuesOf, ) where import Data.Binary (Binary) -import Data.Maybe (catMaybes) +import Data.Maybe (catMaybes, mapMaybe) import Data.Text (Text, pack) import Data.Text qualified as T import Data.Time.Clock (UTCTime (utctDay)) @@ -23,6 +24,15 @@ tagKey (Tag k _) = k tagValue :: Tag -> Maybe Text tagValue (Tag _ v) = v +tagValuesOf :: Text -> [Tag] -> [Text] +tagValuesOf key = + mapMaybe + ( \tag -> + if tagKey tag == key + then tagValue tag + else Nothing + ) + extractTags :: Text -> [Tag] extractTags = catMaybes @@ -38,8 +48,8 @@ extractTags = ) . T.lines -internalTags :: Text -> Maybe Provenance -> [Tag] -internalTags title provenance' = +internalTags :: Text -> Maybe Provenance -> [T.Text] -> [Tag] +internalTags title provenance' markers = concat [ [ Tag "id" $ Just $ toSpinalCase title ], @@ -52,7 +62,8 @@ internalTags title provenance' = Tag "editor" $ Just $ provenance.last.author.name ] ) - provenance' + provenance', + map (Tag "type" . Just) markers ] toSpinalCase :: Text -> Text -- cgit v1.2.3