diff --git a/lib/testutils/src/lib.rs b/lib/testutils/src/lib.rs index a8f398384..42cf22629 100644 --- a/lib/testutils/src/lib.rs +++ b/lib/testutils/src/lib.rs @@ -65,6 +65,10 @@ pub fn user_settings() -> UserSettings { .unwrap() .set_override("user.email", "test.user@example.com") .unwrap() + .set_override("operation.hostname", "host.example.com") + .unwrap() + .set_override("operation.username", "test-username") + .unwrap() .build() .unwrap(); UserSettings::from_config(config) diff --git a/src/config.rs b/src/config.rs index ae1f7d35d..c2e43ab83 100644 --- a/src/config.rs +++ b/src/config.rs @@ -78,6 +78,12 @@ fn env_overrides() -> config::Config { if let Ok(value) = env::var("JJ_TIMESTAMP") { builder = builder.set_override("user.timestamp", value).unwrap(); } + if let Ok(value) = env::var("JJ_OP_HOSTNAME") { + builder = builder.set_override("operation.hostname", value).unwrap(); + } + if let Ok(value) = env::var("JJ_OP_USERNAME") { + builder = builder.set_override("operation.username", value).unwrap(); + } if let Ok(value) = env::var("JJ_EDITOR") { builder = builder.set_override("ui.editor", value).unwrap(); } diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 3b1ef433a..7951038d3 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -72,6 +72,8 @@ impl TestEnvironment { cmd.env("JJ_TIMESTAMP", timestamp.to_rfc3339()); cmd.env("JJ_USER", "Test User"); cmd.env("JJ_EMAIL", "test.user@example.com"); + cmd.env("JJ_OP_HOSTNAME", "host.example.com"); + cmd.env("JJ_OP_USERNAME", "test-username"); cmd } diff --git a/tests/test_operations.rs b/tests/test_operations.rs index c1fa1657d..fe2494bb6 100644 --- a/tests/test_operations.rs +++ b/tests/test_operations.rs @@ -97,7 +97,12 @@ fn test_op_log_configurable() { operation.username = "my-username" "#, ); - test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]); + test_env + .jj_cmd(&test_env.env_root(), &["init", "repo", "--git"]) + .env_remove("JJ_OP_HOSTNAME") + .env_remove("JJ_OP_USERNAME") + .assert() + .success(); let repo_path = test_env.env_root().join("repo"); let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]);