mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 18:54:53 +09:00
Detect README based on file basename
This commit is contained in:
parent
85319ddfdc
commit
35354a18a7
1 changed files with 5 additions and 3 deletions
|
@ -20,16 +20,17 @@ module Vervis.Readme
|
|||
)
|
||||
where
|
||||
|
||||
import Prelude
|
||||
import Prelude hiding (takeWhile)
|
||||
|
||||
import Data.Byteable (toBytes)
|
||||
import Data.ByteString.Lazy (ByteString)
|
||||
import Data.Git.Storage (Git, getObject_)
|
||||
import Data.Git.Storage.Object (Object (..))
|
||||
import Data.Git.Types (Blob (..), Tree (..))
|
||||
import Data.Text (Text, toCaseFold, isPrefixOf, unpack)
|
||||
import Data.Text (Text, toCaseFold, takeWhile, unpack)
|
||||
import Data.Text.Encoding (decodeUtf8With)
|
||||
import Data.Text.Encoding.Error (strictDecode)
|
||||
import System.FilePath (isExtSeparator)
|
||||
|
||||
import Vervis.Foundation (Widget)
|
||||
import Vervis.Render (renderSource)
|
||||
|
@ -42,7 +43,8 @@ findReadme git tree = go $ treeGetEnts tree
|
|||
go [] = return Nothing
|
||||
go ((_perm, name, ref) : es) =
|
||||
let nameT = decodeUtf8With strictDecode $ toBytes name
|
||||
in if toCaseFold "readme" `isPrefixOf` toCaseFold nameT
|
||||
base = takeWhile (not . isExtSeparator) nameT
|
||||
in if toCaseFold "readme" == toCaseFold base
|
||||
then do
|
||||
obj <- getObject_ git ref True
|
||||
case obj of
|
||||
|
|
Loading…
Reference in a new issue