Skip to content

Commit 98f5fcc

Browse files
wxiaoguangSysoev, Vladimir
authored and
Sysoev, Vladimir
committed
Fix dump-repo git init, fix wrong error type for NullDownloader (go-gitea#20182)
* Fix `dump-repo` git init * fix wrong error type for NullDownloader
1 parent 8d7bda2 commit 98f5fcc

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

cmd/dump_repo.go

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strings"
1111

1212
"code.gitea.io/gitea/modules/convert"
13+
"code.gitea.io/gitea/modules/git"
1314
"code.gitea.io/gitea/modules/log"
1415
base "code.gitea.io/gitea/modules/migration"
1516
"code.gitea.io/gitea/modules/setting"
@@ -83,6 +84,11 @@ func runDumpRepository(ctx *cli.Context) error {
8384
return err
8485
}
8586

87+
// migrations.GiteaLocalUploader depends on git module
88+
if err := git.InitSimple(context.Background()); err != nil {
89+
return err
90+
}
91+
8692
log.Info("AppPath: %s", setting.AppPath)
8793
log.Info("AppWorkPath: %s", setting.AppWorkPath)
8894
log.Info("Custom path: %s", setting.CustomPath)

modules/indexer/code/elastic_search.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func (b *ElasticSearchIndexer) Index(ctx context.Context, repo *repo_model.Repos
284284
reqs := make([]elastic.BulkableRequest, 0)
285285
if len(changes.Updates) > 0 {
286286
// Now because of some insanity with git cat-file not immediately failing if not run in a valid git directory we need to run git rev-parse first!
287-
if err := git.EnsureValidGitRepository(git.DefaultContext, repo.RepoPath()); err != nil {
287+
if err := git.EnsureValidGitRepository(ctx, repo.RepoPath()); err != nil {
288288
log.Error("Unable to open git repo: %s for %-v: %v", repo.RepoPath(), repo, err)
289289
return err
290290
}

modules/migration/null_downloader.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,52 @@ func (n NullDownloader) SetContext(_ context.Context) {}
1919

2020
// GetRepoInfo returns a repository information
2121
func (n NullDownloader) GetRepoInfo() (*Repository, error) {
22-
return nil, &ErrNotSupported{Entity: "RepoInfo"}
22+
return nil, ErrNotSupported{Entity: "RepoInfo"}
2323
}
2424

2525
// GetTopics return repository topics
2626
func (n NullDownloader) GetTopics() ([]string, error) {
27-
return nil, &ErrNotSupported{Entity: "Topics"}
27+
return nil, ErrNotSupported{Entity: "Topics"}
2828
}
2929

3030
// GetMilestones returns milestones
3131
func (n NullDownloader) GetMilestones() ([]*Milestone, error) {
32-
return nil, &ErrNotSupported{Entity: "Milestones"}
32+
return nil, ErrNotSupported{Entity: "Milestones"}
3333
}
3434

3535
// GetReleases returns releases
3636
func (n NullDownloader) GetReleases() ([]*Release, error) {
37-
return nil, &ErrNotSupported{Entity: "Releases"}
37+
return nil, ErrNotSupported{Entity: "Releases"}
3838
}
3939

4040
// GetLabels returns labels
4141
func (n NullDownloader) GetLabels() ([]*Label, error) {
42-
return nil, &ErrNotSupported{Entity: "Labels"}
42+
return nil, ErrNotSupported{Entity: "Labels"}
4343
}
4444

4545
// GetIssues returns issues according start and limit
4646
func (n NullDownloader) GetIssues(page, perPage int) ([]*Issue, bool, error) {
47-
return nil, false, &ErrNotSupported{Entity: "Issues"}
47+
return nil, false, ErrNotSupported{Entity: "Issues"}
4848
}
4949

5050
// GetComments returns comments of an issue or PR
5151
func (n NullDownloader) GetComments(commentable Commentable) ([]*Comment, bool, error) {
52-
return nil, false, &ErrNotSupported{Entity: "Comments"}
52+
return nil, false, ErrNotSupported{Entity: "Comments"}
5353
}
5454

5555
// GetAllComments returns paginated comments
5656
func (n NullDownloader) GetAllComments(page, perPage int) ([]*Comment, bool, error) {
57-
return nil, false, &ErrNotSupported{Entity: "AllComments"}
57+
return nil, false, ErrNotSupported{Entity: "AllComments"}
5858
}
5959

6060
// GetPullRequests returns pull requests according page and perPage
6161
func (n NullDownloader) GetPullRequests(page, perPage int) ([]*PullRequest, bool, error) {
62-
return nil, false, &ErrNotSupported{Entity: "PullRequests"}
62+
return nil, false, ErrNotSupported{Entity: "PullRequests"}
6363
}
6464

6565
// GetReviews returns pull requests review
6666
func (n NullDownloader) GetReviews(reviewable Reviewable) ([]*Review, error) {
67-
return nil, &ErrNotSupported{Entity: "Reviews"}
67+
return nil, ErrNotSupported{Entity: "Reviews"}
6868
}
6969

7070
// FormatCloneURL add authentication into remote URLs

0 commit comments

Comments
 (0)