Skip to content

Commit 9b205e9

Browse files
committed
hide EnsureValidGitRepository in git module
1 parent 663a732 commit 9b205e9

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

modules/git/batch_reader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ type WriteCloserError interface {
2626
CloseWithError(err error) error
2727
}
2828

29-
// EnsureValidGitRepository runs git rev-parse in the repository path - thus ensuring that the repository is a valid repository.
29+
// ensureValidGitRepository runs git rev-parse in the repository path - thus ensuring that the repository is a valid repository.
3030
// Run before opening git cat-file.
3131
// This is needed otherwise the git cat-file will hang for invalid repositories.
32-
func EnsureValidGitRepository(ctx context.Context, repoPath string) error {
32+
func ensureValidGitRepository(ctx context.Context, repoPath string) error {
3333
stderr := strings.Builder{}
3434
err := NewCommand(ctx, "rev-parse").
3535
SetDescription(fmt.Sprintf("%s rev-parse [repo_path: %s]", GitExecutable, repoPath)).

modules/git/repo_base_nogogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func OpenRepository(ctx context.Context, repoPath string) (*Repository, error) {
5252
}
5353

5454
// 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!
55-
if err := EnsureValidGitRepository(ctx, repoPath); err != nil {
55+
if err := ensureValidGitRepository(ctx, repoPath); err != nil {
5656
return nil, err
5757
}
5858

modules/indexer/code/elasticsearch/elasticsearch.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
indexer_internal "code.gitea.io/gitea/modules/indexer/internal"
2121
inner_elasticsearch "code.gitea.io/gitea/modules/indexer/internal/elasticsearch"
2222
"code.gitea.io/gitea/modules/json"
23-
"code.gitea.io/gitea/modules/log"
2423
"code.gitea.io/gitea/modules/setting"
2524
"code.gitea.io/gitea/modules/timeutil"
2625
"code.gitea.io/gitea/modules/typesniffer"
@@ -155,12 +154,6 @@ func (b *Indexer) addDelete(filename string, repo *repo_model.Repository) elasti
155154
func (b *Indexer) Index(ctx context.Context, repo *repo_model.Repository, sha string, changes *internal.RepoChanges) error {
156155
reqs := make([]elastic.BulkableRequest, 0)
157156
if len(changes.Updates) > 0 {
158-
// 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!
159-
if err := git.EnsureValidGitRepository(ctx, repo.RepoPath()); err != nil {
160-
log.Error("Unable to open git repo: %s for %-v: %v", repo.RepoPath(), repo, err)
161-
return err
162-
}
163-
164157
r, err := gitrepo.OpenRepository(ctx, repo)
165158
if err != nil {
166159
return err

0 commit comments

Comments
 (0)