UI: Fix and re-enable getRepoCommitsR (i.e. repo history view)

This commit is contained in:
fr33domlover 2022-09-16 12:46:52 +00:00
parent 91cdbf51ab
commit b66bab4295
5 changed files with 37 additions and 58 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,6 +1,7 @@
{- This file is part of Vervis.
-
- Written in 2016, 2018, 2019, 2020 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2016, 2018, 2019, 2020, 2022
- by fr33domlover <fr33domlover@riseup.net>.
-
- 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

View file

@ -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