crates/evaluator: eval loop with git polling and nix-eval-jobs integration

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I291a411b1b06cf821e09f3d5a61403196a6a6964
This commit is contained in:
raf 2026-02-01 15:12:57 +03:00
commit 3fd40b7e07
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
8 changed files with 877 additions and 6 deletions

View file

@ -0,0 +1,28 @@
use std::path::{Path, PathBuf};
use fc_common::error::Result;
use git2::Repository;
/// Clone or fetch a repository. Returns (repo_path, head_commit_hash).
pub fn clone_or_fetch(url: &str, work_dir: &Path, project_name: &str) -> Result<(PathBuf, String)> {
let repo_path = work_dir.join(project_name);
let repo = if repo_path.exists() {
let repo = Repository::open(&repo_path)?;
// Fetch origin — scope the borrow so `remote` is dropped before we move `repo`
{
let mut remote = repo.find_remote("origin")?;
remote.fetch(&["refs/heads/*:refs/remotes/origin/*"], None, None)?;
}
repo
} else {
Repository::clone(url, &repo_path)?
};
// Get HEAD commit hash
let head = repo.head()?;
let commit = head.peel_to_commit()?;
let hash = commit.id().to_string();
Ok((repo_path, hash))
}