summaryrefslogtreecommitdiff
path: root/src/Repo.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-01-19 14:06:29 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2025-01-22 21:28:58 +0100
commitaa113848a5884f95d543c2acecb55321db23b3ba (patch)
tree672b8027a5375ecab1aea78764d56d79fcee761b /src/Repo.hs
parent2e69f4239223b41ada346c340f058ca91342781e (diff)
Option to run tasks for new commits on branch
Diffstat (limited to 'src/Repo.hs')
-rw-r--r--src/Repo.hs14
1 files changed, 10 insertions, 4 deletions
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