feat: refresh diffs when selected jj bookmarks move
This commit is contained in:
@@ -49,6 +49,23 @@ impl Fixture {
|
||||
);
|
||||
String::from_utf8(output.stdout).unwrap().trim().to_owned()
|
||||
}
|
||||
|
||||
fn jj(&self, args: &[&str]) -> String {
|
||||
let output = Command::new("jj")
|
||||
.args(args)
|
||||
.current_dir(self.0.join("repo"))
|
||||
.env("JJ_CONFIG", "/dev/null")
|
||||
.env("JJ_USER", "Diff Fixture")
|
||||
.env("JJ_EMAIL", "fixture@example.invalid")
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
String::from_utf8(output.stdout).unwrap().trim().to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Fixture {
|
||||
@@ -610,3 +627,58 @@ fn branch_changes_default_and_mode_switches_compare_the_selected_divergent_tips(
|
||||
"Working checkout requires Snapshots"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jj_bookmark_picker_keeps_symbolic_targets_searchable_by_resolved_commit_id() {
|
||||
use vamp::diff::RevisionTarget;
|
||||
let fixture = Fixture::new();
|
||||
fixture.jj(&["git", "init", "--no-colocate"]);
|
||||
let source = fixture.0.join("repo/source.txt");
|
||||
fs::write(&source, "base\n").unwrap();
|
||||
fixture.jj(&["describe", "-m", "base"]);
|
||||
let before = fixture.jj(&["log", "--no-graph", "-r", "@", "-T", "commit_id"]);
|
||||
fixture.jj(&["new"]);
|
||||
fs::write(&source, "topic\n").unwrap();
|
||||
fixture.jj(&["describe", "-m", "topic"]);
|
||||
fixture.jj(&["bookmark", "create", "topic"]);
|
||||
let after = fixture.jj(&["log", "--no-graph", "-r", "@", "-T", "commit_id"]);
|
||||
fixture.jj(&["new"]);
|
||||
let mut session = EditorSession::open(Some(source), vec![], None).unwrap();
|
||||
session.execute("diff");
|
||||
wait_until(&mut session, |session| {
|
||||
!session.editor().diff().unwrap().loading
|
||||
});
|
||||
type_query(&mut session, &before);
|
||||
session.handle(Input::Down);
|
||||
session.handle(Input::Enter);
|
||||
session.handle(Input::Char('\t'));
|
||||
type_query(&mut session, &after);
|
||||
let target = RevisionTarget::Bookmark {
|
||||
name: "topic".into(),
|
||||
remote: None,
|
||||
};
|
||||
assert_eq!(
|
||||
session
|
||||
.editor()
|
||||
.diff()
|
||||
.unwrap()
|
||||
.entries()
|
||||
.nth(1)
|
||||
.unwrap()
|
||||
.target,
|
||||
target
|
||||
);
|
||||
session.handle(Input::Down);
|
||||
session.handle(Input::Enter);
|
||||
wait_until(&mut session, |session| {
|
||||
session.editor().diff().unwrap().selected_file_loaded()
|
||||
});
|
||||
let diff = session.editor().diff().unwrap();
|
||||
assert_eq!(
|
||||
diff.before.as_ref().unwrap().target,
|
||||
RevisionTarget::Commit(before)
|
||||
);
|
||||
assert_eq!(diff.after.as_ref().unwrap().target, target);
|
||||
assert_eq!(diff.comparison.as_ref().unwrap().files[0].after, ["topic"]);
|
||||
assert!(!diff.after_editable());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user