mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-16 00:56:23 +00:00
f819dc9345
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
nix / flake check (push) Waiting to run
build / build (, macos-13) (push) Waiting to run
build / build (, macos-14) (push) Waiting to run
build / build (, ubuntu-latest) (push) Waiting to run
build / build (, windows-latest) (push) Waiting to run
build / build (--all-features, ubuntu-latest) (push) Waiting to run
build / Build jj-lib without Git support (push) Waiting to run
build / Check protos (push) Waiting to run
build / Check formatting (push) Waiting to run
build / Check that MkDocs can build the docs (push) Waiting to run
build / Check that MkDocs can build the docs with latest Python and uv (push) Waiting to run
build / cargo-deny (advisories) (push) Waiting to run
build / cargo-deny (bans licenses sources) (push) Waiting to run
build / Clippy check (push) Waiting to run
Codespell / Codespell (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-latest) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Layers are now constructed per file, not per source type. This will allow us to report precise position where bad configuration variable is set. Because layers are now created per file, it makes sense to require existence of the file, instead of ignoring missing files which would leave an empty layer in the stack. The path existence is tested by ConfigEnv::existing_config_path(), so I simply made the new load_file/dir() methods stricter. However, we still need config::File::required(false) flag in order to accept /dev/null as an empty TOML file. The lib type is renamed to StackedConfig to avoid name conflicts. The cli LayeredConfigs will probably be reorganized as an environment object that builds a StackedConfig.
159 lines
5.5 KiB
Rust
159 lines
5.5 KiB
Rust
// Copyright 2023 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::path::PathBuf;
|
|
|
|
use crate::common::TestEnvironment;
|
|
|
|
fn set_up(trunk_name: &str) -> (TestEnvironment, PathBuf) {
|
|
let test_env = TestEnvironment::default();
|
|
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "origin"]);
|
|
let origin_path = test_env.env_root().join("origin");
|
|
let origin_git_repo_path = origin_path
|
|
.join(".jj")
|
|
.join("repo")
|
|
.join("store")
|
|
.join("git");
|
|
|
|
test_env.jj_cmd_ok(&origin_path, &["describe", "-m=description 1"]);
|
|
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", trunk_name]);
|
|
test_env.jj_cmd_ok(&origin_path, &["new", "root()", "-m=description 2"]);
|
|
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "unrelated_bookmark"]);
|
|
test_env.jj_cmd_ok(&origin_path, &["git", "export"]);
|
|
|
|
test_env.jj_cmd_ok(
|
|
test_env.env_root(),
|
|
&[
|
|
"git",
|
|
"clone",
|
|
"--config-toml=git.auto-local-bookmark=true",
|
|
origin_git_repo_path.to_str().unwrap(),
|
|
"local",
|
|
],
|
|
);
|
|
let workspace_root = test_env.env_root().join("local");
|
|
(test_env, workspace_root)
|
|
}
|
|
|
|
#[test]
|
|
fn test_builtin_alias_trunk_matches_main() {
|
|
let (test_env, workspace_root) = set_up("main");
|
|
|
|
let stdout = test_env.jj_cmd_success(&workspace_root, &["log", "-r", "trunk()"]);
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
◆ xtvrqkyv test.user@example.com 2001-02-03 08:05:08 main d13ecdbd
|
|
│ (empty) description 1
|
|
~
|
|
"###);
|
|
}
|
|
|
|
#[test]
|
|
fn test_builtin_alias_trunk_matches_master() {
|
|
let (test_env, workspace_root) = set_up("master");
|
|
|
|
let stdout = test_env.jj_cmd_success(&workspace_root, &["log", "-r", "trunk()"]);
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
◆ xtvrqkyv test.user@example.com 2001-02-03 08:05:08 master d13ecdbd
|
|
│ (empty) description 1
|
|
~
|
|
"###);
|
|
}
|
|
|
|
#[test]
|
|
fn test_builtin_alias_trunk_matches_trunk() {
|
|
let (test_env, workspace_root) = set_up("trunk");
|
|
|
|
let stdout = test_env.jj_cmd_success(&workspace_root, &["log", "-r", "trunk()"]);
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
◆ xtvrqkyv test.user@example.com 2001-02-03 08:05:08 trunk d13ecdbd
|
|
│ (empty) description 1
|
|
~
|
|
"###);
|
|
}
|
|
|
|
#[test]
|
|
fn test_builtin_alias_trunk_matches_exactly_one_commit() {
|
|
let (test_env, workspace_root) = set_up("main");
|
|
let origin_path = test_env.env_root().join("origin");
|
|
test_env.jj_cmd_ok(&origin_path, &["new", "root()", "-m=description 3"]);
|
|
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "master"]);
|
|
|
|
let stdout = test_env.jj_cmd_success(&workspace_root, &["log", "-r", "trunk()"]);
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
◆ xtvrqkyv test.user@example.com 2001-02-03 08:05:08 main d13ecdbd
|
|
│ (empty) description 1
|
|
~
|
|
"###);
|
|
}
|
|
|
|
#[test]
|
|
fn test_builtin_alias_trunk_override_alias() {
|
|
let (test_env, workspace_root) = set_up("override-trunk");
|
|
|
|
test_env.add_config(
|
|
r#"revset-aliases.'trunk()' = 'latest(remote_bookmarks(exact:"override-trunk", exact:"origin"))'"#,
|
|
);
|
|
|
|
let stdout = test_env.jj_cmd_success(&workspace_root, &["log", "-r", "trunk()"]);
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
◆ xtvrqkyv test.user@example.com 2001-02-03 08:05:08 override-trunk d13ecdbd
|
|
│ (empty) description 1
|
|
~
|
|
"###);
|
|
}
|
|
|
|
#[test]
|
|
fn test_builtin_alias_trunk_no_match() {
|
|
let (test_env, workspace_root) = set_up("no-match-trunk");
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["log", "-r", "trunk()"]);
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
◆ zzzzzzzz root() 00000000
|
|
"###);
|
|
insta::assert_snapshot!(stderr, @r###"
|
|
"###);
|
|
}
|
|
|
|
#[test]
|
|
fn test_builtin_alias_trunk_no_match_only_exact() {
|
|
let (test_env, workspace_root) = set_up("maint");
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["log", "-r", "trunk()"]);
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
◆ zzzzzzzz root() 00000000
|
|
"###);
|
|
insta::assert_snapshot!(stderr, @r###"
|
|
"###);
|
|
}
|
|
|
|
#[test]
|
|
fn test_builtin_user_redefines_builtin_immutable_heads() {
|
|
let (test_env, workspace_root) = set_up("main");
|
|
|
|
test_env.add_config(r#"revset-aliases.'builtin_immutable_heads()' = '@'"#);
|
|
test_env.add_config(r#"revset-aliases.'mutable()' = '@'"#);
|
|
test_env.add_config(r#"revset-aliases.'immutable()' = '@'"#);
|
|
|
|
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["log", "-r", "trunk()"]);
|
|
insta::assert_snapshot!(stdout, @r###"
|
|
○ xtvrqkyv test.user@example.com 2001-02-03 08:05:08 main d13ecdbd
|
|
│ (empty) description 1
|
|
~
|
|
"###);
|
|
insta::assert_snapshot!(stderr, @r"
|
|
Warning: Redefining `revset-aliases.builtin_immutable_heads()` is not recommended; redefine `immutable_heads()` instead
|
|
Warning: Redefining `revset-aliases.mutable()` is not recommended; redefine `immutable_heads()` instead
|
|
Warning: Redefining `revset-aliases.immutable()` is not recommended; redefine `immutable_heads()` instead
|
|
");
|
|
}
|