Skip to content

Code monitors: snapshot repo state on code monitor create or update

Administrator requested to merge cc/cm-2 into main

Created by: camdencheek

Due to the somewhat hacky way I've added hooks, it's not currently possible to tell the difference between "this is the first run and we should start from whatever commits exists" and "this is a new repo and we should start searching from the beginning." This fixes that issue by snapshotting the state of things when a code monitor is created or updated so that we can know, unambiguously, that whenever we don't have a set of last-searched hashes, we should just start searching from the beginning.

In the future, when we can optimize a query down to a single commit search job (no and/or jobs), we should be able to remove this hack along with the "job args hash" hack because then we'll be able to do all the code-monitor-specific mutations ahead of time rather than resorting to this hook solution.

Test plan

Manually tested that when I created or updated a monitor, the cm_last_searched table was populated appropriately.

Merge request reports

Loading