Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use alternate fs required by gogit v5.11.0 #31

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions modules/git/repo_base_gogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ func openRepositoryWithDefaultContext(repoPath string) (*Repository, error) {
return OpenRepository(DefaultContext, repoPath)
}

// OpenRepository opens the repository at the given path within the context.Context
// OpenRepository opens the repository at the given path within the context.Context.
func OpenRepository(ctx context.Context, repoPath string) (*Repository, error) {
return OpenRepositoryWithAlternates(ctx, repoPath, "")
}

// OpenRepositoryWithAlternates opens the repository at the given path within the context.Context, with a provided alternate path.
// altPath is ignored if empty.
func OpenRepositoryWithAlternates(ctx context.Context, repoPath string, altPath string) (*Repository, error) {
repoPath, err := filepath.Abs(repoPath)
if err != nil {
return nil, err
Expand All @@ -58,7 +64,14 @@ func OpenRepository(ctx context.Context, repoPath string) (*Repository, error) {
return nil, err
}
}
storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{KeepDescriptors: true, LargeObjectThreshold: setting.Git.LargeObjectThreshold})
options := filesystem.Options{
KeepDescriptors: true,
LargeObjectThreshold: setting.Git.LargeObjectThreshold,
}
if altPath != "" {
options.AlternatesFS = osfs.New(altPath)
}
storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), options)
gogitRepo, err := gogit.Open(storage, fs)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion services/repository/files/temp_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (t *TemporaryUploadRepository) Clone(branch string) error {
}
return fmt.Errorf("Clone: %w %s", err, stderr)
}
gitRepo, err := git.OpenRepository(t.ctx, t.basePath)
gitRepo, err := git.OpenRepositoryWithAlternates(t.ctx, t.basePath, t.repo.RepoPath())
if err != nil {
return err
}
Expand Down