forked from jj-vcs/jj
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
jj debug snapshot
command and use it in trigger
The command only takes a snapshot and avoids other overhead, so it can be used as a target for the watchman trigger that gets installed.
- Loading branch information
Showing
4 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2024 The Jujutsu Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::fmt::Debug; | ||
|
||
use crate::cli_util::CommandHelper; | ||
use crate::command_error::CommandError; | ||
use crate::ui::Ui; | ||
|
||
/// Trigger a snapshot in the op log | ||
#[derive(clap::Args, Clone, Debug)] | ||
pub struct SnapshotArgs {} | ||
|
||
pub fn cmd_debug_snapshot( | ||
ui: &mut Ui, | ||
command: &CommandHelper, | ||
_args: &SnapshotArgs, | ||
) -> Result<(), CommandError> { | ||
// workspace helper will snapshot as needed | ||
command.workspace_helper(ui)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -782,6 +782,42 @@ fn test_workspaces_root() { | |
"###); | ||
} | ||
|
||
#[test] | ||
fn test_debug_snapshot() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); | ||
let repo_path = test_env.env_root().join("repo"); | ||
|
||
std::fs::write(repo_path.join("file"), "contents").unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["debug", "snapshot"]); | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); | ||
insta::assert_snapshot!(stdout, @r###" | ||
@ 2d01fc903f0f [email protected] 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 | ||
│ snapshot working copy | ||
│ args: jj debug snapshot | ||
◉ b51416386f26 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 | ||
│ add workspace 'default' | ||
◉ 9a7d829846af [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 | ||
│ initialize repo | ||
◉ 000000000000 root() | ||
"###); | ||
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "initial"]); | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]); | ||
insta::assert_snapshot!(stdout, @r###" | ||
@ 53a64275e379 [email protected] 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 | ||
│ describe commit 123ed18e4c4c0d77428df41112bc02ffc83fb935 | ||
│ args: jj describe -m initial | ||
◉ 2d01fc903f0f [email protected] 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00 | ||
│ snapshot working copy | ||
│ args: jj debug snapshot | ||
◉ b51416386f26 [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 | ||
│ add workspace 'default' | ||
◉ 9a7d829846af [email protected] 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00 | ||
│ initialize repo | ||
◉ 000000000000 root() | ||
"###); | ||
} | ||
|
||
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String { | ||
let template = r#" | ||
separate(" ", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters