Skip to content

Commit 69fc3e3

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` as a defensive pattern to ignore skill backup files. - Added explanatory comment for the defensive skill backup pattern. - Updated `test_all_gitignore_entries_skips_disabled_agents` to verify that backup patterns are also excluded for disabled agents. - Added a unit test `test_all_gitignore_entries_includes_backup_patterns` to verify the new behavior for enabled agents. - Fixed code style by adding a blank line before the new test. - Verified that all 191 tests pass. Co-authored-by: yacosta738 <33158051+yacosta738@users.noreply.github.com>
1 parent a9a74d5 commit 69fc3e3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ 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());
282+
entries.insert(".agents/skills/*.bak".to_string()); // Defensive pattern to ignore skill backup files even if skills aren't used yet
283283
// Add destinations from all enabled agents and their known patterns
284284
for (agent_name, agent) in &self.agents {
285285
if agent.enabled {
@@ -675,7 +675,9 @@ mod tests {
675675
let entries = config.all_gitignore_entries();
676676

677677
assert!(entries.contains(&"enabled.md".to_string()));
678+
assert!(entries.contains(&"enabled.md.bak.*".to_string()));
678679
assert!(!entries.contains(&"disabled.md".to_string()));
680+
assert!(!entries.contains(&"disabled.md.bak.*".to_string()));
679681
}
680682

681683
#[test]
@@ -1264,6 +1266,7 @@ mod tests {
12641266
assert!(config.gitignore.enabled);
12651267
assert_eq!(config.agents["copilot"].description, "GitHub Copilot");
12661268
}
1269+
12671270
#[test]
12681271
fn test_all_gitignore_entries_includes_backup_patterns() {
12691272
let toml = r#"

0 commit comments

Comments
 (0)