huskies: merge 482_refactor_split_agent_definitions_from_project_toml_into_agents_toml
This commit is contained in:
+22
-13
@@ -90,8 +90,8 @@ pub enum WatcherEvent {
|
||||
},
|
||||
}
|
||||
|
||||
/// Return `true` if `path` is the root-level `.huskies/project.toml`, i.e.
|
||||
/// `{git_root}/.huskies/project.toml`.
|
||||
/// Return `true` if `path` is the root-level `.huskies/project.toml` or
|
||||
/// `.huskies/agents.toml`, i.e. `{git_root}/.huskies/{project,agents}.toml`.
|
||||
///
|
||||
/// Returns `false` for paths inside worktree directories (paths containing
|
||||
/// a `worktrees` component).
|
||||
@@ -100,8 +100,8 @@ pub fn is_config_file(path: &Path, git_root: &Path) -> bool {
|
||||
if path.components().any(|c| c.as_os_str() == "worktrees") {
|
||||
return false;
|
||||
}
|
||||
let expected = git_root.join(".huskies").join("project.toml");
|
||||
path == expected
|
||||
let huskies = git_root.join(".huskies");
|
||||
path == huskies.join("project.toml") || path == huskies.join("agents.toml")
|
||||
}
|
||||
|
||||
/// Map a pipeline directory name to a (action, commit-message-prefix) pair.
|
||||
@@ -421,15 +421,17 @@ pub fn start_watcher(
|
||||
return;
|
||||
}
|
||||
|
||||
// Also watch .huskies/project.toml for hot-reload of agent config.
|
||||
let config_file = git_root.join(".huskies").join("project.toml");
|
||||
if config_file.exists()
|
||||
&& let Err(e) = watcher.watch(&config_file, RecursiveMode::NonRecursive)
|
||||
{
|
||||
slog!(
|
||||
"[watcher] failed to watch config file {}: {e}",
|
||||
config_file.display()
|
||||
);
|
||||
// Also watch .huskies/project.toml and .huskies/agents.toml for hot-reload.
|
||||
let huskies = git_root.join(".huskies");
|
||||
for config_file in [huskies.join("project.toml"), huskies.join("agents.toml")] {
|
||||
if config_file.exists()
|
||||
&& let Err(e) = watcher.watch(&config_file, RecursiveMode::NonRecursive)
|
||||
{
|
||||
slog!(
|
||||
"[watcher] failed to watch config file {}: {e}",
|
||||
config_file.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
slog!("[watcher] watching {}", work_dir.display());
|
||||
@@ -1100,6 +1102,13 @@ mod tests {
|
||||
assert!(is_config_file(&config, &git_root));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_config_file_identifies_root_agents_toml() {
|
||||
let git_root = PathBuf::from("/proj");
|
||||
let agents = git_root.join(".huskies").join("agents.toml");
|
||||
assert!(is_config_file(&agents, &git_root));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_config_file_rejects_worktree_copies() {
|
||||
let git_root = PathBuf::from("/proj");
|
||||
|
||||
Reference in New Issue
Block a user