feat(core): snapshots policy in config and push_snapshots sync option

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5.5 committed 2026-11-16 17:14:29 +01:00
1 parent fc309f9b18
commit 990f155f65
5 files changed
+121 -1

No files matched your search

+42
View File
@@ -15,6 +15,7 @@ fn opts(machine: &str, stamp: &str) -> Options {
remote: "origin".into(),
offline: false,
materialize: true,
push_snapshots: true,
}
}
@@ -168,3 +169,44 @@ fn staged_changes_block_adoption_so_the_index_is_never_reset() {
assert_eq!(r.worktrees[0].state, State::BehindDirty);
assert_eq!(gb.run(&["show", ":a.txt"]).unwrap(), "1\nstaged");
}
#[test]
fn withheld_snapshots_are_neither_taken_nor_pushed_but_fast_forward_still_works() {
let base = tmpdir("nosnap");
let remote = base.join("r.git");
Git::new(&base)
.run(&[
"init",
"-q",
"--bare",
"-b",
"main",
remote.to_str().unwrap(),
])
.unwrap();
let seed = init(&base.join("seed"));
seed.run(&["remote", "add", "origin", remote.to_str().unwrap()])
.unwrap();
commit(&seed, "a.txt", "1\n");
seed.run(&["push", "-q", "-u", "origin", "main"]).unwrap();
let (_g, d) = clone(&base, &remote, "A");
fs::write(d.join("a.txt"), "1\nsecret\n").unwrap();
let o = Options {
push_snapshots: false,
..opts("A", "t1")
};
let r = sync_repo(&d, &o).unwrap();
assert_eq!(r.worktrees[0].snapshot, None);
let g = Git::new(&remote);
assert!(g.run(&["for-each-ref", "refs/sync/"]).unwrap().is_empty());
// Fast-forwarding keeps working.
commit(&seed, "b.txt", "2\n");
seed.run(&["push", "-q"]).unwrap();
fs::write(d.join("a.txt"), "1\n").unwrap();
let r = sync_repo(&d, &o).unwrap();
assert!(matches!(
r.worktrees[0].received,
Some(Received::FastForwarded { .. })
));
assert!(d.join("b.txt").exists());
}