diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-04-19 21:40:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-19 21:40:42 +0800 |
commit | e422342eebc18034ef586ec58f1e2fff0340091d (patch) | |
tree | 307264b46c1683915429083d54e9634ee4f2fc4d /modules/indexer | |
parent | 01214c8ada993bf5f54a4149979d140443d69410 (diff) | |
download | gitea-e422342eebc18034ef586ec58f1e2fff0340091d.tar.gz gitea-e422342eebc18034ef586ec58f1e2fff0340091d.zip |
Allow adding new files to an empty repo (#24164)
![image](https://user-images.githubusercontent.com/2114189/232561612-2bfcfd0a-fc04-47ba-965f-5d0bcea46c54.png)
Diffstat (limited to 'modules/indexer')
-rw-r--r-- | modules/indexer/code/indexer.go | 4 | ||||
-rw-r--r-- | modules/indexer/stats/db.go | 7 | ||||
-rw-r--r-- | modules/indexer/stats/queue.go | 5 |
3 files changed, 12 insertions, 4 deletions
diff --git a/modules/indexer/code/indexer.go b/modules/indexer/code/indexer.go index 027d13555c..2c493ccf94 100644 --- a/modules/indexer/code/indexer.go +++ b/modules/indexer/code/indexer.go @@ -154,7 +154,9 @@ func Init() { log.Trace("IndexerData Process Repo: %d", indexerData.RepoID) if err := index(ctx, indexer, indexerData.RepoID); err != nil { - log.Error("index: %v", err) + if !setting.IsInTesting { + log.Error("indexer index error for repo %v: %v", indexerData.RepoID, err) + } if indexer.Ping() { continue } diff --git a/modules/indexer/stats/db.go b/modules/indexer/stats/db.go index 9bbdcad60d..2a0475dea6 100644 --- a/modules/indexer/stats/db.go +++ b/modules/indexer/stats/db.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" + "code.gitea.io/gitea/modules/setting" ) // DBIndexer implements Indexer interface to use database's like search @@ -46,7 +47,7 @@ func (db *DBIndexer) Index(id int64) error { // Get latest commit for default branch commitID, err := gitRepo.GetBranchCommitID(repo.DefaultBranch) if err != nil { - if git.IsErrBranchNotExist(err) || git.IsErrNotExist(err) { + if git.IsErrBranchNotExist(err) || git.IsErrNotExist(err) || setting.IsInTesting { log.Debug("Unable to get commit ID for default branch %s in %s ... skipping this repository", repo.DefaultBranch, repo.RepoPath()) return nil } @@ -62,7 +63,9 @@ func (db *DBIndexer) Index(id int64) error { // Calculate and save language statistics to database stats, err := gitRepo.GetLanguageStats(commitID) if err != nil { - log.Error("Unable to get language stats for ID %s for default branch %s in %s. Error: %v", commitID, repo.DefaultBranch, repo.RepoPath(), err) + if !setting.IsInTesting { + log.Error("Unable to get language stats for ID %s for default branch %s in %s. Error: %v", commitID, repo.DefaultBranch, repo.RepoPath(), err) + } return err } err = repo_model.UpdateLanguageStats(repo, commitID, stats) diff --git a/modules/indexer/stats/queue.go b/modules/indexer/stats/queue.go index 32379f2859..a57338e07d 100644 --- a/modules/indexer/stats/queue.go +++ b/modules/indexer/stats/queue.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/queue" + "code.gitea.io/gitea/modules/setting" ) // statsQueue represents a queue to handle repository stats updates @@ -20,7 +21,9 @@ func handle(data ...queue.Data) []queue.Data { for _, datum := range data { opts := datum.(int64) if err := indexer.Index(opts); err != nil { - log.Error("stats queue indexer.Index(%d) failed: %v", opts, err) + if !setting.IsInTesting { + log.Error("stats queue indexer.Index(%d) failed: %v", opts, err) + } } } return nil |