mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 18:27:38 +00:00
cli: fix "workspace list" to use current workspace to format commit summary
It doesn't matter for the default commit-summary template, but it should be the workspace the user operates on, not the one currently listing.
This commit is contained in:
parent
4a17bc0302
commit
8d27bb0f27
2 changed files with 36 additions and 1 deletions
|
@ -3737,7 +3737,7 @@ fn cmd_workspace_list(
|
||||||
write_commit_summary(
|
write_commit_summary(
|
||||||
ui.stdout_formatter().as_mut(),
|
ui.stdout_formatter().as_mut(),
|
||||||
repo.as_repo_ref(),
|
repo.as_repo_ref(),
|
||||||
workspace_id,
|
&workspace_command.workspace_id(),
|
||||||
&commit,
|
&commit,
|
||||||
command.settings(),
|
command.settings(),
|
||||||
)?;
|
)?;
|
||||||
|
|
|
@ -209,6 +209,41 @@ fn test_workspaces_forget() {
|
||||||
insta::assert_snapshot!(stdout, @"");
|
insta::assert_snapshot!(stdout, @"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test context of commit summary template
|
||||||
|
#[test]
|
||||||
|
fn test_list_workspaces_template() {
|
||||||
|
let test_env = TestEnvironment::default();
|
||||||
|
test_env.jj_cmd_success(test_env.env_root(), &["init", "--git", "main"]);
|
||||||
|
test_env.add_config(
|
||||||
|
br###"
|
||||||
|
template.commit_summary = """commit_id.short() " " description.first_line()
|
||||||
|
if(current_working_copy, " (current)")"""
|
||||||
|
"###,
|
||||||
|
);
|
||||||
|
let main_path = test_env.env_root().join("main");
|
||||||
|
let secondary_path = test_env.env_root().join("secondary");
|
||||||
|
|
||||||
|
std::fs::write(main_path.join("file"), "contents").unwrap();
|
||||||
|
test_env.jj_cmd_success(&main_path, &["commit", "-m", "initial"]);
|
||||||
|
test_env.jj_cmd_success(
|
||||||
|
&main_path,
|
||||||
|
&["workspace", "add", "--name", "second", "../secondary"],
|
||||||
|
);
|
||||||
|
|
||||||
|
// "current_working_copy" should point to the workspace we operate on
|
||||||
|
let stdout = test_env.jj_cmd_success(&main_path, &["workspace", "list"]);
|
||||||
|
insta::assert_snapshot!(stdout, @r###"
|
||||||
|
default: e0e6d5672858 (no description set) (current)
|
||||||
|
second: f68da2d114f1 (no description set)
|
||||||
|
"###);
|
||||||
|
|
||||||
|
let stdout = test_env.jj_cmd_success(&secondary_path, &["workspace", "list"]);
|
||||||
|
insta::assert_snapshot!(stdout, @r###"
|
||||||
|
default: e0e6d5672858 (no description set)
|
||||||
|
second: f68da2d114f1 (no description set) (current)
|
||||||
|
"###);
|
||||||
|
}
|
||||||
|
|
||||||
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
|
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
|
||||||
test_env.jj_cmd_success(
|
test_env.jj_cmd_success(
|
||||||
cwd,
|
cwd,
|
||||||
|
|
Loading…
Reference in a new issue