mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-28 17:41:14 +00:00
jj debug operation --display id
option to show current operation id for tests
I also considered `jj operation id`, but I'm not sure this is useful outside tests
This commit is contained in:
parent
14e19d0692
commit
fa1e961f53
2 changed files with 19 additions and 0 deletions
|
@ -75,6 +75,8 @@ pub struct DebugOperationArgs {
|
|||
pub enum DebugOperationDisplay {
|
||||
/// Show only the operation details.
|
||||
Operation,
|
||||
/// Show the operation id only
|
||||
Id,
|
||||
/// Show only the view details
|
||||
View,
|
||||
/// Show both the view and the operation
|
||||
|
@ -158,6 +160,10 @@ pub fn cmd_debug(
|
|||
DebugCommands::Operation(operation_args) => {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let op = workspace_command.resolve_single_op(&operation_args.operation)?;
|
||||
if operation_args.display == DebugOperationDisplay::Id {
|
||||
writeln!(ui, "{}", op.id().hex())?;
|
||||
return Ok(());
|
||||
}
|
||||
if operation_args.display != DebugOperationDisplay::View {
|
||||
writeln!(ui, "{:#?}", op.store_operation())?;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,19 @@ fn test_debug_reindex() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_debug_operation_id() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let workspace_path = test_env.env_root().join("repo");
|
||||
let stdout =
|
||||
test_env.jj_cmd_success(&workspace_path, &["debug", "operation", "--display", "id"]);
|
||||
assert_snapshot!(filter_index_stats(&stdout), @r###"
|
||||
a99a3fd5c51e8f7ccb9ae2f9fb749612a23f0a7cf25d8c644f36c35c077449ce3c66f49d098a5a704ca5e47089a7f019563a5b8cbc7d451619e0f90c82241ceb
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
fn filter_index_stats(text: &str) -> String {
|
||||
let regex = Regex::new(r" Name: [0-9a-z]+").unwrap();
|
||||
regex.replace_all(text, " Name: [hash]").to_string()
|
||||
|
|
Loading…
Reference in a new issue