mirror of
https://code.sup39.dev/repos/Wqawg
synced 2025-01-15 02:35:10 +09:00
Fix homepage repo table: Failed for empty repos
This commit is contained in:
parent
ec4c7de582
commit
1fe41edabe
2 changed files with 10 additions and 11 deletions
|
@ -72,14 +72,16 @@ lastBranchChange git branch = do
|
||||||
return $ fromMaybe (error "mtime is Nothing") mtime
|
return $ fromMaybe (error "mtime is Nothing") mtime
|
||||||
|
|
||||||
-- | Determine the time of the last commit in any branch for a given repo
|
-- | Determine the time of the last commit in any branch for a given repo
|
||||||
lastChange :: FilePath -> IO DateTime
|
lastChange :: FilePath -> IO (Maybe DateTime)
|
||||||
lastChange path = withRepo (fromString path) $ \ git -> do
|
lastChange path = withRepo (fromString path) $ \ git -> do
|
||||||
--TODO add a better intro to json-state, the docs are bad there
|
--TODO add a better intro to json-state, the docs are bad there
|
||||||
|
|
||||||
names <- branchList git
|
names <- branchList git
|
||||||
times <- traverse (lastBranchChange git) $ map refNameRaw $ toList names
|
times <- traverse (lastBranchChange git) $ map refNameRaw $ toList names
|
||||||
let datetimes = map timeConvert times
|
let datetimes = map timeConvert times
|
||||||
return $ maximum datetimes
|
return $ if null datetimes
|
||||||
|
then Nothing
|
||||||
|
else Just $ maximum datetimes
|
||||||
|
|
||||||
showPeriod :: Period -> Text
|
showPeriod :: Period -> Text
|
||||||
showPeriod (Period 0 0 d) = T.pack (show d) <> " days"
|
showPeriod (Period 0 0 d) = T.pack (show d) <> " days"
|
||||||
|
|
|
@ -42,17 +42,14 @@ intro = do
|
||||||
, project ^. ProjectIdent
|
, project ^. ProjectIdent
|
||||||
, repo ^. RepoIdent
|
, repo ^. RepoIdent
|
||||||
)
|
)
|
||||||
|
root <- appRepoDir . appSettings <$> getYesod
|
||||||
liftIO $ forM repos $ \ (Value sharer, Value project, Value repo) -> do
|
liftIO $ forM repos $ \ (Value sharer, Value project, Value repo) -> do
|
||||||
let path =
|
let path =
|
||||||
unpack $
|
root </> unpack sharer </> unpack project </> unpack repo
|
||||||
intercalate "/"
|
mdt <- lastChange path
|
||||||
[ "state2"
|
ago <- case mdt of
|
||||||
, sharer
|
Nothing -> return "never"
|
||||||
, project
|
Just dt -> timeAgo dt
|
||||||
, repo
|
|
||||||
]
|
|
||||||
dt <- lastChange path
|
|
||||||
ago <- timeAgo dt
|
|
||||||
return (sharer, project, repo, ago)
|
return (sharer, project, repo, ago)
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Welcome to Vervis!"
|
setTitle "Welcome to Vervis!"
|
||||||
|
|
Loading…
Reference in a new issue