mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 16:34:52 +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
|
||||
|
||||
-- | 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
|
||||
--TODO add a better intro to json-state, the docs are bad there
|
||||
|
||||
names <- branchList git
|
||||
times <- traverse (lastBranchChange git) $ map refNameRaw $ toList names
|
||||
let datetimes = map timeConvert times
|
||||
return $ maximum datetimes
|
||||
return $ if null datetimes
|
||||
then Nothing
|
||||
else Just $ maximum datetimes
|
||||
|
||||
showPeriod :: Period -> Text
|
||||
showPeriod (Period 0 0 d) = T.pack (show d) <> " days"
|
||||
|
|
|
@ -42,17 +42,14 @@ intro = do
|
|||
, project ^. ProjectIdent
|
||||
, repo ^. RepoIdent
|
||||
)
|
||||
root <- appRepoDir . appSettings <$> getYesod
|
||||
liftIO $ forM repos $ \ (Value sharer, Value project, Value repo) -> do
|
||||
let path =
|
||||
unpack $
|
||||
intercalate "/"
|
||||
[ "state2"
|
||||
, sharer
|
||||
, project
|
||||
, repo
|
||||
]
|
||||
dt <- lastChange path
|
||||
ago <- timeAgo dt
|
||||
root </> unpack sharer </> unpack project </> unpack repo
|
||||
mdt <- lastChange path
|
||||
ago <- case mdt of
|
||||
Nothing -> return "never"
|
||||
Just dt -> timeAgo dt
|
||||
return (sharer, project, repo, ago)
|
||||
defaultLayout $ do
|
||||
setTitle "Welcome to Vervis!"
|
||||
|
|
Loading…
Reference in a new issue