aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue.hs
diff options
context:
space:
mode:
authorLibravatar Fabian Kirchner <kirchner@posteo.de>2023-10-13 22:51:12 +0200
committerLibravatar Fabian Kirchner <kirchner@posteo.de>2023-10-13 22:51:12 +0200
commitddb4861554c96d2f3f3734eebc358f78c034da7d (patch)
tree95611baf34a8da7cdc1824dd90242764082c4feb /app/Issue.hs
parent73f3b070e7f710bea00ad83f9714fba90a75974b (diff)
only show prov info in show command
Diffstat (limited to 'app/Issue.hs')
-rw-r--r--app/Issue.hs37
1 files changed, 23 insertions, 14 deletions
diff --git a/app/Issue.hs b/app/Issue.hs
index e37c20e..fabd88f 100644
--- a/app/Issue.hs
+++ b/app/Issue.hs
@@ -5,11 +5,14 @@
module Issue (Issue (..), Provenance (..), fromMatch, id) where
+import Data.ByteString.Lazy (toStrict)
import Data.ByteString.Lazy.Char8 (unpack)
import Data.List (find, foldl')
import Data.String (fromString)
import Data.Text (Text)
import Data.Text qualified as T
+import Data.Text.Encoding (decodeUtf8)
+import Data.Time.Clock (UTCTime)
import Issue.Tag (Tag (..))
import Issue.Tag qualified as I
import Issue.Text qualified as I
@@ -25,7 +28,7 @@ data Issue = Issue
{ title :: Text,
description :: Maybe Text,
file :: String,
- provenance :: Provenance,
+ provenance :: Maybe Provenance,
start :: G.Position,
end :: G.Position,
tags :: [Tag],
@@ -34,7 +37,10 @@ data Issue = Issue
deriving (Show)
data Provenance = Provenance
- { firstCommit :: Maybe String
+ { firstCommit :: Text,
+ date :: UTCTime,
+ authorEmail :: Text,
+ authorName :: Text
}
deriving (Show)
@@ -47,29 +53,32 @@ id issue =
fromMatch :: G.Result -> G.Match -> IO (Maybe Issue)
fromMatch result match = do
- firstCommits <-
- fmap (lines . unpack) $
+ rawProvenance <-
+ fmap (map (T.splitOn "\NUL") . T.lines . decodeUtf8 . toStrict) $
sh $
( fromString
( printf
- "git --no-pager log --reverse -S\"$(cat %s | tail -n+%d | head -%d)\" --format=%%H -- %s"
+ "git --no-pager log --reverse -S\"$(cat %s | tail -n+%d | head -%d)\" --format='%%H%%x00%%ai%%x00%%ae%%x00%%an' -- %s"
(quote result.file)
match.start.row
(match.end.row - match.start.row + 1)
(quote result.file)
)
)
- let firstCommit =
- case firstCommits of
- [] ->
+ let provenance =
+ case rawProvenance of
+ (firstCommit' : rawDate : authorEmail : authorName : _) : _ ->
+ let date = read (T.unpack rawDate)
+ in Just
+ Provenance
+ { firstCommit = firstCommit',
+ date = date,
+ authorEmail = authorEmail,
+ authorName = authorName
+ }
+ _ ->
Nothing
- firstCommit' : _ ->
- Just firstCommit'
- provenance =
- Provenance
- { firstCommit = firstCommit
- }
pure
( if any (\marker -> T.isPrefixOf marker title') issueMarkers
then