Skip to content

Commit

Permalink
Put optimization behind temporary feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jtibshirani committed Oct 30, 2024
1 parent 5da54b9 commit 7af6e78
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions gitindex/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,23 @@ func indexGitRepo(opts Options, config gitIndexConfig) (bool, error) {

opts.BuildOptions.RepositoryDescription.Source = opts.RepoDir

repo, repoCloser, err := openRepo(opts.RepoDir)
if err != nil {
return false, fmt.Errorf("openRepo: %w", err)
var repo *git.Repository

// TODO: remove this feature flag once we test this on a large-scale instance.
optimizeRepoOpen := os.Getenv("ZOEKT_ENABLE_GOGIT_OPTIMIZATION")
if b, err := strconv.ParseBool(optimizeRepoOpen); b && err == nil {
var repoCloser io.Closer
repo, repoCloser, err = openRepo(opts.RepoDir)
if err != nil {
return false, fmt.Errorf("openRepo: %w", err)
}
defer repoCloser.Close()
} else {
repo, err = git.PlainOpen(opts.RepoDir)
if err != nil {
return false, fmt.Errorf("git.PlainOpen: %w", err)
}
}
defer repoCloser.Close()

if err := setTemplatesFromConfig(&opts.BuildOptions.RepositoryDescription, opts.RepoDir); err != nil {
log.Printf("setTemplatesFromConfig(%s): %s", opts.RepoDir, err)
Expand Down

0 comments on commit 7af6e78

Please sign in to comment.