readd err debug

This commit is contained in:
6543 2022-09-18 19:47:20 +02:00
commit bcb7d773d1
No known key found for this signature in database
GPG key ID: B8BE6D610E61C862
2 changed files with 8 additions and 2 deletions

View file

@ -5,16 +5,21 @@ import (
"path"
"strings"
"github.com/rs/zerolog/log"
"codeberg.org/codeberg/pages/server/gitea"
)
// GetBranchTimestamp finds the default branch (if branch is "") and returns the last modification time of the branch
// (or nil if the branch doesn't exist)
func GetBranchTimestamp(giteaClient *gitea.Client, owner, repo, branch string) *gitea.BranchTimestamp {
log := log.With().Strs("BranchInfo", []string{owner, repo, branch}).Logger()
if len(branch) == 0 {
// Get default branch
defaultBranch, err := giteaClient.GiteaGetRepoDefaultBranch(owner, repo)
if err != nil {
log.Error().Err(err).Msg("GiteaGetRepoDefaultBranch")
return nil
}
branch = defaultBranch
@ -22,6 +27,7 @@ func GetBranchTimestamp(giteaClient *gitea.Client, owner, repo, branch string) *
timestamp, err := giteaClient.GiteaGetRepoBranchTimestamp(owner, repo, branch)
if err != nil {
log.Error().Err(err).Msg("GiteaGetRepoBranchTimestamp")
return nil
}
return timestamp