From ff5535f0a55201c6883c48c3892c9ef357904356 Mon Sep 17 00:00:00 2001
From: Alexander Foremny <aforemny@posteo.de>
Date: Thu, 30 Nov 2023 03:21:59 +0100
Subject: feat: show commit references in show command

---
 app/Issue/Meta.hs |  2 +-
 app/Main.hs       | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/app/Issue/Meta.hs b/app/Issue/Meta.hs
index d9851ec..4c237a4 100644
--- a/app/Issue/Meta.hs
+++ b/app/Issue/Meta.hs
@@ -21,7 +21,7 @@ getMeta issues issue =
           ( \issueOther ->
               let tagsRelevant =
                     filter (\tag -> tagValue tag == fmap T.pack issue.id) issueOther.tags
-               in map (\tag -> (issue, tag)) tagsRelevant
+               in map (\tag -> (issueOther, tag)) tagsRelevant
           )
           issues
     }
diff --git a/app/Main.hs b/app/Main.hs
index a16ee7e..06327c4 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -235,19 +235,6 @@
 -- @topic dependencies
 -- @backlog
 
--- TODO Relations between issues
---
--- Issues should be able to refer to other issues (via id) within their tags,
--- ie. `@supersedes target-issue-id`. Such relations should create issue
--- events on the target issue, and recording the source issue id that created
--- the relation.
---
--- This might serve as ground work for dependencies-between-issues.
---
--- @related dependencies-between-issues
--- @priority high
--- @assigned Alexander Foremny
-
 -- TODO Add fulltext search
 --
 -- Additional to `--filter` it should be possible to search for issues
@@ -384,6 +371,7 @@
 module Main where
 
 import Control.Applicative ((<|>))
+import Control.Monad (when)
 import Data.Function ((&))
 import Data.List (find, intersperse, isPrefixOf)
 import Data.List.Extra (list)
@@ -702,6 +690,18 @@ main = do
                 ++ "\n@row "
                 ++ show issue.start.row
                 ++ "\n"
+          when (not $ null meta.referencedBy) $
+            putDoc colorize True width . P.annotate (P.color P.Black) . P.vsep $
+              P.pretty ("" :: T.Text)
+                : map
+                  ( \(otherIssue, tag) ->
+                      P.pretty ("This commit was referenced by issue " :: T.Text)
+                        <> P.annotate P.bold (P.pretty otherIssue.id)
+                        <> P.pretty (" (" :: T.Text)
+                        <> P.annotate P.bold (P.pretty ("@" <> I.tagKey tag))
+                        <> P.pretty (")." :: T.Text)
+                  )
+                  meta.referencedBy
     Options {colorize, noPager, width, internalTags, command = Tags} -> do
       issues <- trd3 . last <$> getHistory
       let tags =
-- 
cgit v1.2.3