Skip to content

repos: have `diff.Modified` track which field(s) changed in a sync

Warren Gifford requested to merge aharvey/make-modified-a-bitfield into main

Created by: LawnGnome

This split out of a discussion in #38702, where we were grappling with how to signal that a specific field had been modified in a repo when it was synced. @ryanslade suggested extending Modified to be more than a simple slice of repos, and after implementing it, I actually quite like it.

Basically, Modified is now a slice of structs with the repo and a bitfield indicating what fields were modified. There are currently 10 fields and it's a uint64, so we have some future proofing there.

Most existing uses of Diff.Modified were simply replaced with Diff.Modified.Repos(), and then the Diff.ArchivedChanged field added in #38702 could be removed completely.

Technically, RepoModified doesn't need to be a Stringer, but I quickly found it made debugging unit tests considerably easier to have it. I suggest we keep it just for that.

Tagging @sourcegraph/batchers as reviewers here as well, but just for the little bit that touches Batch Changes. This one's mostly for @sourcegraph/repo-management.

Test plan

Basically using the unit tests: we have pretty good coverage here. Running Sourcegraph locally for a while with this still synced as expected.

Merge request reports

Loading