MCPcopy Index your code
hub / github.com/coder/coder / markStaleSingle

Method markStaleSingle

coderd/x/gitsync/worker.go:327–355  ·  view source on GitHub ↗

markStaleSingle upserts the git ref for a single chat and publishes a diff-status change event.

(
	ctx context.Context,
	chatID uuid.UUID,
	branch, origin string,
)

Source from the content-addressed store, hash-verified

325// markStaleSingle upserts the git ref for a single chat and
326// publishes a diff-status change event.
327func (w *Worker) markStaleSingle(
328 ctx context.Context,
329 chatID uuid.UUID,
330 branch, origin string,
331) {
332 _, err := w.store.UpsertChatDiffStatusReference(ctx,
333 database.UpsertChatDiffStatusReferenceParams{
334 ChatID: chatID,
335 GitBranch: branch,
336 GitRemoteOrigin: origin,
337 StaleAt: w.clock.Now().Add(-time.Second),
338 Url: sql.NullString{},
339 },
340 )
341 if err != nil {
342 w.logger.Warn(ctx, "store git ref on chat diff status",
343 slog.F("chat_id", chatID),
344 slog.Error(err))
345 return
346 }
347 // Notify the frontend immediately so the UI shows the
348 // branch info even before the worker refreshes PR data.
349 if w.publishDiffStatusChangeFn != nil {
350 if pubErr := w.publishDiffStatusChangeFn(ctx, chatID); pubErr != nil {
351 w.logger.Debug(ctx, "publish diff status after mark stale",
352 slog.F("chat_id", chatID), slog.Error(pubErr))
353 }
354 }
355}
356
357// RefreshChat synchronously refreshes a single chat's diff
358// status using the same Refresher pipeline as the background

Callers 1

MarkStaleMethod · 0.95

Calls 3

AddMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected