1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2025-01-15 03:55:08 +09:00

If Git repo is empty (no branches), don't 404, just show basic repo page

This commit is contained in:
fr33domlover 2019-10-19 06:01:14 +00:00
parent 0be7f05d31
commit 339c2253f9

View file

@ -119,29 +119,30 @@ loadSourceView git refT dir = do
tags <- G.tagList git
let refS = T.unpack refT
refN = RefName refS
msv <- if refN `S.member` branches || refN `S.member` tags
then do
tipOid <- resolveName git refS
mtree <- G.resolveTreeish git $ unObjId tipOid
case mtree of
Nothing -> return Nothing
Just tree -> do
let dir' = map (G.entName . encodeUtf8) dir
view <- viewPath git tree dir'
Just <$> case view of
RootView rows -> do
mreadme <- findReadme git rows
let ents = map rowToEntry rows
return $ SourceDir $
DirectoryView Nothing ents mreadme
TreeView name _ rows -> do
mreadme <- findReadme git rows
let ents = map rowToEntry rows
return $ SourceDir $
DirectoryView (Just name) ents mreadme
BlobView name _ body ->
return $ SourceFile $ FileView name body
else return Nothing
msv <-
if null branches
then return $ Just $ SourceDir $ DirectoryView Nothing [] Nothing
else if refN `S.member` branches || refN `S.member` tags
then do
tipOid <- resolveName git refS
mtree <- G.resolveTreeish git $ unObjId tipOid
for mtree $ \ tree -> do
let dir' = map (G.entName . encodeUtf8) dir
view <- viewPath git tree dir'
case view of
RootView rows -> do
mreadme <- findReadme git rows
let ents = map rowToEntry rows
return $ SourceDir $
DirectoryView Nothing ents mreadme
TreeView name _ rows -> do
mreadme <- findReadme git rows
let ents = map rowToEntry rows
return $ SourceDir $
DirectoryView (Just name) ents mreadme
BlobView name _ body ->
return $ SourceFile $ FileView name body
else return Nothing
return (branches, tags, msv)
readSourceView