From b66bab4295035ac9a153efe3cd7e536c883a2765 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Fri, 16 Sep 2022 12:46:52 +0000 Subject: [PATCH] UI: Fix and re-enable getRepoCommitsR (i.e. repo history view) --- src/Vervis/Darcs.hs | 6 ++---- src/Vervis/Git.hs | 8 ++++---- src/Vervis/Handler/Repo.hs | 21 ++++++++------------- src/Vervis/Web/Darcs.hs | 30 ++++++++++++------------------ src/Vervis/Web/Git.hs | 30 +++++++++++------------------- 5 files changed, 37 insertions(+), 58 deletions(-) diff --git a/src/Vervis/Darcs.hs b/src/Vervis/Darcs.hs index d02976e..43262ca 100644 --- a/src/Vervis/Darcs.hs +++ b/src/Vervis/Darcs.hs @@ -17,9 +17,9 @@ module Vervis.Darcs ( --readSourceView --, readWikiView - --, readChangesView + readChangesView --, lastChange - readPatch + , readPatch , writePostApplyHooks --, applyDarcsPatch ) @@ -220,7 +220,6 @@ readWikiView isPage isMain path dir = do for mpage $ \ (load, mmtitle) -> mkview mmtitle <$> load -} -{- readChangesView :: FilePath -- ^ Repository path @@ -261,7 +260,6 @@ lastChange path now = fmap maybeRight $ runExceptT $ do intervalToEventTime $ FriendlyConvert $ now `diffUTCTime` piTime pi --} data Change = AddFile FilePath diff --git a/src/Vervis/Git.hs b/src/Vervis/Git.hs index b85622b..0893963 100644 --- a/src/Vervis/Git.hs +++ b/src/Vervis/Git.hs @@ -16,9 +16,9 @@ module Vervis.Git ( --readSourceView - --, readChangesView - --, listRefs - readPatch + readChangesView + , listRefs + , readPatch --, lastCommitTime , writePostReceiveHooks --, applyGitPatches @@ -171,6 +171,7 @@ readSourceView path ref dir = do G.withRepo (fromString path) $ \ git -> loadSourceView git ref dir let toTexts = S.mapMonotonic $ T.pack . refNameRaw return (toTexts bs, toTexts ts, renderSources dir <$> msv) +-} readChangesView :: FilePath @@ -213,7 +214,6 @@ readChangesView path ref off lim = G.withRepo (fromString path) $ \ git -> do listRefs :: FilePath -> IO (Set Text, Set Text) listRefs path = G.withRepo (fromString path) $ \ git -> (,) <$> listBranches git <*> listTags git --} patch :: [Edit] -> Commit SHA1 -> P.Patch patch edits c = P.Patch diff --git a/src/Vervis/Handler/Repo.hs b/src/Vervis/Handler/Repo.hs index 9b62bf0..924495e 100644 --- a/src/Vervis/Handler/Repo.hs +++ b/src/Vervis/Handler/Repo.hs @@ -111,7 +111,7 @@ import Text.Pandoc.Highlighting import Yesod.Auth import Yesod.Core hiding (joinPath) import Yesod.Core.Content -import Yesod.Core.Handler (lookupPostParam, redirect, notFound) +import Yesod.Core.Handler import Yesod.Form.Functions (runFormPost) import Yesod.Form.Types (FormResult (..)) import Yesod.Persist.Core @@ -379,24 +379,19 @@ getRepoCommitsR repoHash = do repoID <- decodeKeyHashid404 repoHash repo <- runDB $ get404 repoID case repoVcs repo of - VCSDarcs -> - error "Temporarily disabled" - --getDarcsRepoHeadChanges repoHash - VCSGit -> - error "Temporarily disabled" - --getGitRepoHeadChanges repo repoHash + VCSDarcs -> getDarcsRepoChanges repoHash + VCSGit -> selectRep $ do + AP.provideAP (notFound :: Handler ()) + provideRepType typeHtml + ((redirect $ RepoBranchCommitsR repoHash $ repoMainBranch repo) :: Handler ()) getRepoBranchCommitsR :: KeyHashid Repo -> Text -> Handler TypedContent getRepoBranchCommitsR repoHash branch = do repoID <- decodeKeyHashid404 repoHash repo <- runDB $ get404 repoID case repoVcs repo of - VCSDarcs -> - error "Temporarily disabled" - --getDarcsRepoChanges repoHash branch - VCSGit -> - error "Temporarily disabled" - --getGitRepoChanges repoHash branch + VCSDarcs -> notFound + VCSGit -> getGitRepoChanges repoHash branch getRepoCommitR :: KeyHashid Repo -> Text -> Handler TypedContent getRepoCommitR repoHash ref = do diff --git a/src/Vervis/Web/Darcs.hs b/src/Vervis/Web/Darcs.hs index fcecb11..d4315a2 100644 --- a/src/Vervis/Web/Darcs.hs +++ b/src/Vervis/Web/Darcs.hs @@ -1,6 +1,7 @@ {- This file is part of Vervis. - - - Written in 2016, 2018, 2019, 2020 by fr33domlover . + - Written in 2016, 2018, 2019, 2020, 2022 + - by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - @@ -15,9 +16,8 @@ module Vervis.Web.Darcs ( --getDarcsRepoSource - --, getDarcsRepoHeadChanges - --, getDarcsRepoChanges - getDarcsPatch + getDarcsRepoChanges + , getDarcsPatch ) where @@ -72,6 +72,7 @@ import Vervis.SourceTree import Vervis.Style import Vervis.Time import Vervis.Web.Repo +import Vervis.Widget.Repo import qualified Vervis.Darcs as D @@ -101,11 +102,10 @@ getDarcsRepoSource (mproject, repository) user repo dir = do (return $ repoFollowers repository) -} -{- -getDarcsRepoHeadChanges :: ShrIdent -> RpIdent -> Handler TypedContent -getDarcsRepoHeadChanges shar repo = do - path <- askRepoDir shar repo - let here = RepoHeadChangesR shar repo +getDarcsRepoChanges :: KeyHashid Repo -> Handler TypedContent +getDarcsRepoChanges repo = do + path <- askRepoDir repo + let here = RepoCommitsR repo encodeRouteLocal <- getEncodeRouteLocal encodeRouteHome <- getEncodeRouteHome encodeRoutePageLocal <- getEncodeRoutePageLocal @@ -149,20 +149,14 @@ getDarcsRepoHeadChanges shar repo = do else Nothing , collectionPageStartIndex = Nothing , collectionPageItems = - map (encodeRouteHome . RepoCommitR shar repo . leHash) + map (encodeRouteHome . RepoCommitR repo . leHash) items } - feed = changeFeed shar repo Nothing VCSDarcs items + feed = changeFeed repo Nothing VCSDarcs items in provideHtmlFeedAndAP page feed $ - let changes = changesW shar repo items + let changes = changesW repo items pageNav = navWidget navModel in $(widgetFile "repo/changes-darcs") --} - -{- -getDarcsRepoChanges :: ShrIdent -> RpIdent -> Text -> Handler TypedContent -getDarcsRepoChanges shar repo tag = notFound --} getDarcsPatch :: KeyHashid Repo -> Text -> Handler TypedContent getDarcsPatch hash ref = do diff --git a/src/Vervis/Web/Git.hs b/src/Vervis/Web/Git.hs index 64d97d4..3e0eba1 100644 --- a/src/Vervis/Web/Git.hs +++ b/src/Vervis/Web/Git.hs @@ -16,10 +16,9 @@ module Vervis.Web.Git ( --getGitRepoSource - --, getGitRepoHeadChanges --, getGitRepoBranch - --, getGitRepoChanges - getGitPatch + getGitRepoChanges + , getGitPatch ) where @@ -89,6 +88,7 @@ import Vervis.SourceTree import Vervis.Style import Vervis.Time (showDate) import Vervis.Web.Repo +import Vervis.Widget.Repo import qualified Data.ByteString.Lazy as BL (ByteString) import qualified Vervis.Git as G @@ -119,12 +119,6 @@ getGitRepoSource (mproject, repository) user repo ref dir = do (return $ repoFollowers repository) -} -{- -getGitRepoHeadChanges :: Repo -> ShrIdent -> RpIdent -> Handler TypedContent -getGitRepoHeadChanges repository shar repo = - getGitRepoChanges shar repo $ repoMainBranch repository --} - {- getGitRepoBranch :: ShrIdent -> RpIdent -> Text -> Handler TypedContent getGitRepoBranch shar repo ref = do @@ -143,14 +137,13 @@ getGitRepoBranch shar repo ref = do else notFound -} -{- -getGitRepoChanges :: ShrIdent -> RpIdent -> Text -> Handler TypedContent -getGitRepoChanges shar repo ref = do - path <- askRepoDir shar repo +getGitRepoChanges :: KeyHashid Repo -> Text -> Handler TypedContent +getGitRepoChanges repo ref = do + path <- askRepoDir repo (branches, tags) <- liftIO $ G.listRefs path unless (ref `S.member` branches || ref `S.member` tags) notFound - let here = RepoChangesR shar repo ref + let here = RepoBranchCommitsR repo ref encodeRouteLocal <- getEncodeRouteLocal encodeRouteHome <- getEncodeRouteHome encodeRoutePageLocal <- getEncodeRoutePageLocal @@ -190,16 +183,15 @@ getGitRepoChanges shar repo ref = do else Nothing , collectionPageStartIndex = Nothing , collectionPageItems = - map (encodeRouteHome . RepoCommitR shar repo . leHash) + map (encodeRouteHome . RepoCommitR repo . leHash) items } - feed = changeFeed shar repo (Just ref) VCSGit items + feed = changeFeed repo (Just ref) VCSGit items in provideHtmlFeedAndAP page feed $ - let refSelect = refSelectW shar repo branches tags - changes = changesW shar repo items + let refSelect = refSelectW repo branches tags + changes = changesW repo items pageNav = navWidget navModel in $(widgetFile "repo/changes-git") --} getGitPatch :: KeyHashid Repo -> Text -> Handler TypedContent getGitPatch hash ref = do