FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

repo-updater: some docs for uses of repos.Diff (#11694) · meonBot/sourcegraph@325a54c · GitHub

Commit 325a54c

Browse files
authored
repo-updater: some docs for uses of repos.Diff (sourcegraph#11694)
1 parent ac23db0 commit 325a54c

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

‎cmd/repo-updater/repos/scheduler.go‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,24 @@ var configuredLimiter = func() *mutablelimiter.Limiter {
225225
return limiter
226226
}
227227

228-
// UpdateFromDiff updates the scheduled and queued repos from the given sync diff.
228+
// UpdateFromDiff updates the scheduled and queued repos from the given sync
229+
// diff.
230+
//
231+
// We upsert all repos that exist to the scheduler. This is so the
232+
// scheduler can track the repositories and periodically update
233+
// them.
234+
//
235+
// Items on the update queue will be cloned/fetched as soon as
236+
// possible. We treat repos differently depending on which part of the
237+
// diff they are:
238+
//
239+
//
240+
// Deleted - remove from scheduler and queue.
241+
// Added - new repo, enqueue for asap clone.
242+
// Modified - likely new url or name. May also be a sign of new
243+
// commits. Enqueue for asap clone (or fetch).
244+
// Unmodified - we likely already have this cloned. Just rely on
245+
// the scheduler and do not enqueue.
229246
func (s *updateScheduler) UpdateFromDiff(diff Diff) {
230247
for _, r := range diff.Deleted {
231248
s.remove(r)
@@ -262,6 +279,11 @@ func (s *updateScheduler) SetCloned(names []string) {
262279
s.schedule.setCloned(names)
263280
}
264281

282+
// upsert adds r to the scheduler for periodic updates. If r.ID is already in
283+
// the scheduler, then the fields are updated (upsert).
284+
//
285+
// If enqueue is true then r is also enqueued to the update queue for a git
286+
// fetch/clone soon.
265287
func (s *updateScheduler) upsert(r *Repo, enqueue bool) {
266288
repo := configuredRepo2FromRepo(r)
267289

‎cmd/repo-updater/repos/syncer.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,17 @@ func (s *Syncer) initialUnmodifiedDiffFromStore(ctx context.Context) {
268268
return
269269
}
270270

271+
// Assuming sources returns no differences from the last sync, the Diff
272+
// would be just a list of all stored repos Unmodified. This is the steady
273+
// state, so is the initial diff we choose.
271274
select {
272275
case s.Synced <- Diff{Unmodified: stored}:
273276
case <-ctx.Done():
274277
}
275278
}
276279

277-
// A Diff of two sets of Diffables.
280+
// Diff is the difference found by a sync between what is in the store and
281+
// what is returned from sources.
278282
type Diff struct {
279283
Added Repos
280284
Deleted Repos

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL