-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Move git clone management to a seperate API #58
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
base: main
Are you sure you want to change the base?
Conversation
| m.clones[upstreamURL] = repo | ||
| m.clonesMu.Unlock() | ||
|
|
||
| return nil |
There was a problem hiding this comment.
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.
| "-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())), |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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), "/") |
There was a problem hiding this comment.
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
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.