2022-11-26 23:57:50 +00:00
|
|
|
// Copyright 2020 The Jujutsu Authors
|
2020-12-12 08:00:42 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2024-08-22 18:18:15 +00:00
|
|
|
use crate::common::TestEnvironment;
|
2022-03-30 17:47:11 +00:00
|
|
|
|
2022-10-09 05:33:51 +00:00
|
|
|
#[test]
|
|
|
|
fn test_init_local_disallowed() {
|
|
|
|
let test_env = TestEnvironment::default();
|
|
|
|
let stdout = test_env.jj_cmd_failure(test_env.env_root(), &["init", "repo"]);
|
|
|
|
insta::assert_snapshot!(stdout, @r###"
|
2022-11-12 23:28:32 +00:00
|
|
|
Error: The native backend is disallowed by default.
|
2024-01-08 10:41:07 +00:00
|
|
|
Hint: Did you mean to call `jj git init`?
|
2022-10-09 05:33:51 +00:00
|
|
|
Set `ui.allow-init-native` to allow initializing a repo with the native backend.
|
|
|
|
"###);
|
|
|
|
}
|
|
|
|
|
2020-12-12 08:00:42 +00:00
|
|
|
#[test]
|
|
|
|
fn test_init_local() {
|
2022-01-16 06:06:12 +00:00
|
|
|
let test_env = TestEnvironment::default();
|
2023-01-26 19:26:18 +00:00
|
|
|
test_env.add_config(r#"ui.allow-init-native = true"#);
|
2023-10-10 11:59:18 +00:00
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo"]);
|
2023-10-10 11:07:06 +00:00
|
|
|
insta::assert_snapshot!(stdout, @"");
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
2022-04-28 23:32:18 +00:00
|
|
|
Initialized repo in "repo"
|
|
|
|
"###);
|
2022-03-05 01:51:02 +00:00
|
|
|
|
2022-03-09 22:12:32 +00:00
|
|
|
let workspace_root = test_env.env_root().join("repo");
|
2022-01-29 04:26:16 +00:00
|
|
|
let jj_path = workspace_root.join(".jj");
|
|
|
|
let repo_path = jj_path.join("repo");
|
|
|
|
let store_path = repo_path.join("store");
|
|
|
|
assert!(workspace_root.is_dir());
|
|
|
|
assert!(jj_path.is_dir());
|
|
|
|
assert!(jj_path.join("working_copy").is_dir());
|
2020-12-12 08:00:42 +00:00
|
|
|
assert!(repo_path.is_dir());
|
2022-01-29 04:26:16 +00:00
|
|
|
assert!(store_path.is_dir());
|
|
|
|
assert!(store_path.join("commits").is_dir());
|
|
|
|
assert!(store_path.join("trees").is_dir());
|
|
|
|
assert!(store_path.join("files").is_dir());
|
|
|
|
assert!(store_path.join("symlinks").is_dir());
|
|
|
|
assert!(store_path.join("conflicts").is_dir());
|
2024-07-23 04:50:03 +00:00
|
|
|
|
|
|
|
let stderr = test_env.jj_cmd_cli_error(
|
|
|
|
test_env.env_root(),
|
|
|
|
&["init", "--ignore-working-copy", "repo2"],
|
|
|
|
);
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
|
|
|
Error: --ignore-working-copy is not respected
|
|
|
|
"###);
|
|
|
|
|
|
|
|
let stderr = test_env.jj_cmd_cli_error(test_env.env_root(), &["init", "--at-op=@-", "repo3"]);
|
|
|
|
insta::assert_snapshot!(stderr, @r###"
|
|
|
|
Error: --at-op is not respected
|
|
|
|
"###);
|
2020-12-12 08:00:42 +00:00
|
|
|
}
|