From 6e2dacfef6e329408c4de18852d4950d457a9135 Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 22 Apr 2021 21:30:18 +0100 Subject: [PATCH] If the default branch is not present do not report error on stats indexing (follow-up of #15546) (#15583) (#15594) Backport #15546 Backport #15583 #15546 doesn't completely fix this problem because the error returned is an ObjectNotExist error not a BranchNotExist error. Add test for ErrObjectNotExist too Fix #15257 Signed-off-by: Andrew Thornton --- modules/indexer/stats/db.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/indexer/stats/db.go b/modules/indexer/stats/db.go index bc3fbc13d893..976bf2d632d6 100644 --- a/modules/indexer/stats/db.go +++ b/modules/indexer/stats/db.go @@ -38,7 +38,11 @@ func (db *DBIndexer) Index(id int64) error { // Get latest commit for default branch commitID, err := gitRepo.GetBranchCommitID(repo.DefaultBranch) if err != nil { - log.Error("Unable to get commit ID for defaultbranch %s in %s", repo.DefaultBranch, repo.RepoPath()) + if git.IsErrBranchNotExist(err) || git.IsErrNotExist((err)) { + log.Debug("Unable to get commit ID for defaultbranch %s in %s ... skipping this repository", repo.DefaultBranch, repo.RepoPath()) + return nil + } + log.Error("Unable to get commit ID for defaultbranch %s in %s. Error: %v", repo.DefaultBranch, repo.RepoPath(), err) return err }