Skip to content

Conversation

@js-murph
Copy link
Collaborator

What?

Migrates the git clone component of the git strategy into a separate API

Why?

Experimentation on implementing private repo support for the gomod strategy in #56 revealed we are likely better off separating the git clone behaviour so that it can be shared between multiple strategies.

@js-murph js-murph requested a review from alecthomas as a code owner January 23, 2026 04:30
m.clones[upstreamURL] = repo
m.clonesMu.Unlock()

return nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this point we've discovered the git repo, so we can return fs.SkipDir to not recurse further.

Comment on lines +266 to +268
"-c", "http.postBuffer="+strconv.Itoa(config.GitConfig.PostBuffer),
"-c", "http.lowSpeedLimit="+strconv.Itoa(config.GitConfig.LowSpeedLimit),
"-c", "http.lowSpeedTime="+strconv.Itoa(int(config.GitConfig.LowSpeedTime.Seconds())),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice


r.mu.Lock()
r.lastFetch = time.Now()
r.mu.Unlock()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be keeping the lock while we're fetching?

return
}
// #nosec G204 - repo.Path() is controlled by us
cmd := exec.CommandContext(ctx, "git", "-C", repo.Path(), "bundle", "create", "-", "--branches", "--remotes")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should still be here?

s.generateAndUploadBundle(ctx, c)
func (s *Strategy) scheduleBundleJobs(repo *gitclone.Repository) {
s.scheduler.SubmitPeriodicJob(repo.UpstreamURL(), "bundle-periodic", s.config.BundleInterval, func(ctx context.Context) error {
s.generateAndUploadBundle(ctx, repo)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether we should move the bundling into gitclone as well, to isolate all git operations. It's probably fine..

return errors.Wrap(err, "get relative path")
}

parts := strings.Split(filepath.ToSlash(relPath), "/")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably from the other code, but we should be using filepath.Split() and filepath.Join() instead of strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants