From aa113848a5884f95d543c2acecb55321db23b3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 19 Jan 2025 14:06:29 +0100 Subject: Option to run tasks for new commits on branch --- src/Repo.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Repo.hs') diff --git a/src/Repo.hs b/src/Repo.hs index caa8a20..fbcd2ed 100644 --- a/src/Repo.hs +++ b/src/Repo.hs @@ -1,7 +1,7 @@ module Repo ( Repo, Commit, commitId, - CommitId, showCommitId, - TreeId, showTreeId, + CommitId, textCommitId, showCommitId, + TreeId, textTreeId, showTreeId, openRepo, readBranch, @@ -77,12 +77,18 @@ instance Eq Commit where newtype CommitId = CommitId ByteString deriving (Eq, Ord) +textCommitId :: CommitId -> Text +textCommitId (CommitId cid) = decodeUtf8 cid + showCommitId :: CommitId -> String showCommitId (CommitId cid) = BC.unpack cid newtype TreeId = TreeId ByteString deriving (Eq, Ord) +textTreeId :: TreeId -> Text +textTreeId (TreeId tid) = decodeUtf8 tid + showTreeId :: TreeId -> String showTreeId (TreeId tid) = BC.unpack tid @@ -124,9 +130,9 @@ readBranch repo branch = readCommitFromFile repo ("refs/heads" T.unpack bran readTag :: MonadIO m => Repo -> Text -> m (Maybe Commit) readTag repo tag = readCommitFromFile repo ("refs/tags" T.unpack tag) -listCommits :: MonadIO m => Repo -> String -> m [ Commit ] +listCommits :: MonadIO m => Repo -> Text -> m [ Commit ] listCommits commitRepo range = liftIO $ do - out <- readProcess "git" [ "log", "--pretty=%H", "--first-parent", "--reverse", range ] "" + out <- readProcess "git" [ "log", "--pretty=%H", "--first-parent", "--reverse", T.unpack range ] "" forM (lines out) $ \cid -> do let commitId_ = CommitId (BC.pack cid) commitDetails <- newMVar Nothing -- cgit v1.2.3