Skip to content

Commit a9a74d5

Browse files
feat: ignore backup files in .gitignore by default
This change ensures that backup files created by AgentSync (e.g., when replacing an existing file with a symlink or during skill updates) are automatically ignored by Git. Changes: - In `src/config.rs`, `all_gitignore_entries()` now includes: - `{destination}.bak.*` for every target destination. - `.agents/skills/*.bak` for skill update backups. - Added a unit test `test_all_gitignore_entries_includes_backup_patterns` to verify the new behavior. - Verified that all 191 tests pass. Co-authored-by: yacosta738 <33158051+yacosta738@users.noreply.github.com>
1 parent b202ac1 commit a9a74d5

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/config.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,14 @@ impl Config {
279279
pub fn all_gitignore_entries(&self) -> Vec<String> {
280280
let mut entries: BTreeSet<String> = self.gitignore.entries.iter().cloned().collect();
281281

282+
entries.insert(".agents/skills/*.bak".to_string());
282283
// Add destinations from all enabled agents and their known patterns
283284
for (agent_name, agent) in &self.agents {
284285
if agent.enabled {
285286
// Add target destinations
286287
for target in agent.targets.values() {
287288
entries.insert(target.destination.clone());
289+
entries.insert(format!("{}.bak.*", target.destination));
288290
}
289291

290292
// Add known ignore patterns for this agent
@@ -1262,4 +1264,22 @@ mod tests {
12621264
assert!(config.gitignore.enabled);
12631265
assert_eq!(config.agents["copilot"].description, "GitHub Copilot");
12641266
}
1267+
#[test]
1268+
fn test_all_gitignore_entries_includes_backup_patterns() {
1269+
let toml = r#"
1270+
[agents.test]
1271+
enabled = true
1272+
[agents.test.targets.main]
1273+
source = "README.md"
1274+
destination = "OUTPUT.md"
1275+
type = "symlink"
1276+
"#;
1277+
1278+
let config: Config = toml::from_str(toml).unwrap();
1279+
let entries = config.all_gitignore_entries();
1280+
1281+
assert!(entries.contains(&"OUTPUT.md".to_string()));
1282+
assert!(entries.contains(&"OUTPUT.md.bak.*".to_string()));
1283+
assert!(entries.contains(&".agents/skills/*.bak".to_string()));
1284+
}
12651285
}

0 commit comments

Comments
 (0)