Compare commits

...

2 Commits

Author SHA1 Message Date
Nils Koch
deb4f1ba79 docs: update git compatibility docs for commit signing 2025-05-04 22:52:24 +00:00
Martin von Zweigbergk
103d05149d cli: add "$schema" line when creating new config file
It seems like a small usability improvement if users don't need to
enter the "$schema" link manually when they create a new config file.

This doesn't help existing users.
2025-05-04 17:14:10 +00:00
3 changed files with 31 additions and 9 deletions

View File

@ -231,6 +231,7 @@ fn test_config_list_layer() {
let output = work_dir.run_jj(["config", "list", "--user"]); let output = work_dir.run_jj(["config", "list", "--user"]);
insta::assert_snapshot!(output, @r#" insta::assert_snapshot!(output, @r#"
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json"
test-key = "test-val" test-key = "test-val"
test-layered-key = "test-original-val" test-layered-key = "test-original-val"
[EOF] [EOF]
@ -255,6 +256,7 @@ fn test_config_list_layer() {
let output = work_dir.run_jj(["config", "list", "--repo"]); let output = work_dir.run_jj(["config", "list", "--repo"]);
insta::assert_snapshot!(output, @r#" insta::assert_snapshot!(output, @r#"
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json"
test-layered-key = "test-layered-val" test-layered-key = "test-layered-val"
[EOF] [EOF]
"#); "#);
@ -304,6 +306,7 @@ fn test_config_list_origin() {
]); ]);
insta::assert_snapshot!(output, @r#" insta::assert_snapshot!(output, @r#"
test-key = "test-val" # user $TEST_ENV/config/config.toml test-key = "test-val" # user $TEST_ENV/config/config.toml
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json" # repo $TEST_ENV/repo/.jj/repo/config.toml
test-layered-key = "test-layered-val" # repo $TEST_ENV/repo/.jj/repo/config.toml test-layered-key = "test-layered-val" # repo $TEST_ENV/repo/.jj/repo/config.toml
user.name = "Test User" # env user.name = "Test User" # env
user.email = "test.user@example.com" # env user.email = "test.user@example.com" # env
@ -597,6 +600,7 @@ fn test_config_set_for_user() {
let user_config_toml = std::fs::read_to_string(&user_config_path) let user_config_toml = std::fs::read_to_string(&user_config_path)
.unwrap_or_else(|_| panic!("Failed to read file {}", user_config_path.display())); .unwrap_or_else(|_| panic!("Failed to read file {}", user_config_path.display()));
insta::assert_snapshot!(user_config_toml, @r#" insta::assert_snapshot!(user_config_toml, @r#"
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json"
test-key = "test-val" test-key = "test-val"
[test-table] [test-table]
@ -663,6 +667,7 @@ fn test_config_set_for_repo() {
// Ensure test-key successfully written to user config. // Ensure test-key successfully written to user config.
let repo_config_toml = work_dir.read_file(".jj/repo/config.toml"); let repo_config_toml = work_dir.read_file(".jj/repo/config.toml");
insta::assert_snapshot!(repo_config_toml, @r#" insta::assert_snapshot!(repo_config_toml, @r#"
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json"
test-key = "test-val" test-key = "test-val"
[test-table] [test-table]
@ -691,6 +696,8 @@ fn test_config_set_toml_types() {
set_value("test-table.string", r#""foo""#); set_value("test-table.string", r#""foo""#);
set_value("test-table.invalid", r"a + b"); set_value("test-table.invalid", r"a + b");
insta::assert_snapshot!(std::fs::read_to_string(&user_config_path).unwrap(), @r#" insta::assert_snapshot!(std::fs::read_to_string(&user_config_path).unwrap(), @r#"
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json"
[test-table] [test-table]
integer = 42 integer = 42
float = 3.14 float = 3.14
@ -784,7 +791,10 @@ fn test_config_unset_inline_table_key() {
.run_jj(["config", "unset", "--user", "inline-table.foo"]) .run_jj(["config", "unset", "--user", "inline-table.foo"])
.success(); .success();
let user_config_toml = std::fs::read_to_string(&user_config_path).unwrap(); let user_config_toml = std::fs::read_to_string(&user_config_path).unwrap();
insta::assert_snapshot!(user_config_toml, @"inline-table = {}"); insta::assert_snapshot!(user_config_toml, @r#"
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json"
inline-table = {}
"#);
} }
#[test] #[test]
@ -856,7 +866,11 @@ fn test_config_unset_for_user() {
.success(); .success();
let user_config_toml = std::fs::read_to_string(&user_config_path).unwrap(); let user_config_toml = std::fs::read_to_string(&user_config_path).unwrap();
insta::assert_snapshot!(user_config_toml, @"[table]"); insta::assert_snapshot!(user_config_toml, @r#"
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json"
[table]
"#);
} }
#[test] #[test]
@ -873,7 +887,7 @@ fn test_config_unset_for_repo() {
.success(); .success();
let repo_config_toml = work_dir.read_file(".jj/repo/config.toml"); let repo_config_toml = work_dir.read_file(".jj/repo/config.toml");
insta::assert_snapshot!(repo_config_toml, @""); insta::assert_snapshot!(repo_config_toml, @r#""$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json""#);
} }
#[test] #[test]

View File

@ -68,9 +68,9 @@ a comparison with Git, including how workflows are different, see the
copies backed by a single repo. See the `jj workspace` family of commands. copies backed by a single repo. See the `jj workspace` family of commands.
* **Sparse checkouts: No.** However, there's native support for sparse * **Sparse checkouts: No.** However, there's native support for sparse
checkouts. See the `jj sparse` command. checkouts. See the `jj sparse` command.
* **Signed commits: Partial.** * **Signed commits: Yes.**
So far only [by configuration](https://github.com/jj-vcs/jj/blob/main/docs/config.md#commit-signing), You can sign commits automatically [by configuration](https://github.com/jj-vcs/jj/blob/main/docs/config.md#commit-signing),
later perhaps [a command](https://github.com/jj-vcs/jj/pull/3142). or use the `jj sign` command.
* **Git LFS: No.** ([#80](https://github.com/jj-vcs/jj/issues/80)) * **Git LFS: No.** ([#80](https://github.com/jj-vcs/jj/issues/80))

View File

@ -559,11 +559,19 @@ impl ConfigFile {
Err(ConfigLoadError::Read(PathError { path, error })) Err(ConfigLoadError::Read(PathError { path, error }))
if error.kind() == io::ErrorKind::NotFound => if error.kind() == io::ErrorKind::NotFound =>
{ {
Arc::new(ConfigLayer { let mut data = DocumentMut::new();
data.insert(
"$schema",
toml_edit::Item::Value(
"https://jj-vcs.github.io/jj/latest/config-schema.json".into(),
),
);
let layer = ConfigLayer {
source, source,
path: Some(path), path: Some(path),
data: DocumentMut::new(), data,
}) };
Arc::new(layer)
} }
Err(err) => return Err(err), Err(err) => return Err(err),
}; };