MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / init_baseline

Function init_baseline

src/watcher/watcher.c:486–509  ·  view source on GitHub ↗

Init baseline for a project: check if git, get HEAD, count files */

Source from the content-addressed store, hash-verified

484
485/* Init baseline for a project: check if git, get HEAD, count files */
486static void init_baseline(project_state_t *s) {
487 struct stat st;
488 if (stat(s->root_path, &st) != 0) {
489 cbm_log_warn("watcher.root_gone", "project", s->project_name, "path", s->root_path);
490 s->baseline_done = true;
491 s->is_git = false;
492 return;
493 }
494
495 s->is_git = is_git_repo(s->root_path);
496 s->baseline_done = true;
497
498 if (s->is_git) {
499 git_head(s->root_path, s->last_head, sizeof(s->last_head));
500 s->file_count = git_file_count(s->root_path);
501 s->interval_ms = cbm_watcher_poll_interval_ms(s->file_count);
502 cbm_log_info("watcher.baseline", "project", s->project_name, "strategy", "git", "files",
503 s->file_count > 0 ? "yes" : "0");
504 } else {
505 cbm_log_info("watcher.baseline", "project", s->project_name, "strategy", "none");
506 }
507
508 s->next_poll_ns = now_ns() + ((int64_t)s->interval_ms * US_PER_MS);
509}
510
511/* Check if a project has changes. Returns true if reindex needed. */
512static bool check_changes(project_state_t *s) {

Callers 1

poll_projectFunction · 0.85

Calls 6

is_git_repoFunction · 0.85
git_headFunction · 0.85
git_file_countFunction · 0.85
statClass · 0.70
now_nsFunction · 0.70

Tested by

no test coverage detected