From 9e9e7fc803675af46072d6587c22adf93d844d76 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 11 Apr 2016 22:13:32 +0000 Subject: [PATCH] Display repo files in repo page instead of history log --- src/Vervis/Handler/Repo.hs | 25 ++++++++++--------------- stack.yaml | 3 ++- templates/repo/repo.hamlet | 16 ++++++---------- vervis.cabal | 1 + 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/Vervis/Handler/Repo.hs b/src/Vervis/Handler/Repo.hs index 98b5d37..0981a35 100644 --- a/src/Vervis/Handler/Repo.hs +++ b/src/Vervis/Handler/Repo.hs @@ -35,10 +35,11 @@ import ClassyPrelude.Conduit hiding (unpack) import Yesod hiding (Header, parseTime, (==.)) import Yesod.Auth +import Data.Byteable (toBytes) import Data.Git.Graph import Data.Git.Graph.Util import Data.Git.Ref (toHex) -import Data.Git.Repository (initRepo) +import Data.Git.Repository (initRepo, getCommit, getTree) import Data.Git.Storage (withRepo) import Data.Git.Types (Commit (..), Person (..)) import Data.Graph.Inductive.Graph (noNodes) @@ -120,23 +121,17 @@ getRepoR user proj repo = do Entity _rid r <- getBy404 $ UniqueRepo repo pid return r path <- askRepoDir user proj repo - pairs <- liftIO $ withRepo (fromString path) $ \ git -> do + view <- liftIO $ withRepo (fromString path) $ \ git -> do oid <- resolveName git $ unpack $ repoMainBranch repository - graph <- loadCommitGraphPT git [oid] - let mnodes = topsortUnmixOrder graph (NodeStack [noNodes graph]) - nodes = case mnodes of - Nothing -> error "commit graph contains a cycle" - Just ns -> ns - return $ D.toList $ fmap (nodeLabel graph) nodes - now <- liftIO dateCurrent + commit <- getCommit git $ unObjId oid + tree <- getTree git $ commitTreeish commit + viewTree git tree let toText = decodeUtf8With lenientDecode - mkrow oid commit = - ( toText $ personName $ commitAuthor commit - , toText $ toHex $ unObjId oid - , toText $ takeLine $ commitMessage commit - , timeAgo' now (timeConvert $ personTime $ commitAuthor commit) + mkrow (_perm, name, isTree) = + ( if isTree then "[D]" else "[F]" :: Text + , toText $ toBytes name ) - rows = map (uncurry mkrow) pairs + rows = map mkrow view defaultLayout $ do setTitle $ toHtml $ intercalate " > " $ ["Vervis", "People", user, "Projects", proj, "Repos", repo] diff --git a/stack.yaml b/stack.yaml index acbc0fe..700b7dd 100644 --- a/stack.yaml +++ b/stack.yaml @@ -8,7 +8,8 @@ resolver: lts-5.11 # Local packages, usually specified by relative directory name packages: - '.' - - '/home/fr33domlover/Repos/other-work/ssh' + - '../../../other-work/ssh' + - '../hit-graph' # Packages to be pulled from upstream that are not in the resolver (e.g., # acme-missiles-0.3) diff --git a/templates/repo/repo.hamlet b/templates/repo/repo.hamlet index 73930fc..bf2d8d6 100644 --- a/templates/repo/repo.hamlet +++ b/templates/repo/repo.hamlet @@ -29,16 +29,12 @@ $# . $nothing (none) -

History +

Files - -
Author - Hash - Message - Time - $forall (author, hash, message, time) <- rows + Type + Name + $forall (type', name) <- rows
#{author} - #{hash} - #{message} - #{time} + #{type'} + #{name} diff --git a/vervis.cabal b/vervis.cabal index e0ddebe..67597f3 100644 --- a/vervis.cabal +++ b/vervis.cabal @@ -87,6 +87,7 @@ library , base64-bytestring , binary , blaze-html + , byteable , bytestring , case-insensitive , classy-prelude