Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

* Add support for `--when.workspaces` config scopes.

* Add support for `--when.hostnames` config scopes. This allows configuration to
be conditionally applied based on the hostname set in `operation.hostname`.

* `jj bisect run` accepts the command and arguments to pass to the command
directly as positional arguments, such as
`jj bisect --range=..main -- cargo check --all-targets`.
Expand Down
7 changes: 7 additions & 0 deletions cli/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,13 @@
"type": "string"
}
},
"hostnames": {
"type": "array",
"description": "List of hostnames to match the hostname",
"items": {
"type": "string"
}
},
"workspaces": {
"type": "array",
"description": "List of paths to match the workspace path prefix",
Expand Down
4 changes: 4 additions & 0 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ pub struct ConfigEnv {
repo_config_path: Option<ConfigPath>,
workspace_config_path: Option<ConfigPath>,
command: Option<String>,
hostname: Option<String>,
}

impl ConfigEnv {
Expand Down Expand Up @@ -423,6 +424,7 @@ impl ConfigEnv {
repo_config_path: None,
workspace_config_path: None,
command: None,
hostname: whoami::fallible::hostname().ok(),
}
}

Expand Down Expand Up @@ -602,6 +604,7 @@ impl ConfigEnv {
repo_path: self.repo_path.as_deref(),
workspace_path: self.workspace_path.as_deref(),
command: self.command.as_deref(),
hostname: self.hostname.as_deref().unwrap_or(""),
};
jj_lib::config::resolve(config.as_ref(), &context)
}
Expand Down Expand Up @@ -1852,6 +1855,7 @@ mod tests {
repo_config_path: None,
workspace_config_path: None,
command: None,
hostname: None,
}
}
}
16 changes: 16 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,12 @@ email = "[email protected]"
[--scope.user]
email = "[email protected]"

# override ui.pager on specific machines
[[--scope]]
--when.hostnames = ["work-laptop", "work-desktop"]
[--scope.ui]
pager = "delta"

# disable pagination for `jj status`, use `delta` for `jj diff` and `jj show`
[[--scope]]
--when.commands = ["status"]
Expand Down Expand Up @@ -1940,6 +1946,16 @@ wip = ["log", "-r", "work"]

Use `jj root` to see the workspace root directory.

* `--when.hostnames`: List of hostnames to match against the `operation.hostname`
config setting.

Hostnames are compared case-sensitively and must match exactly.

```toml
--when.hostnames = ["work-laptop"] # matches only "work-laptop"
--when.hostnames = ["home-desktop", "laptop"] # matches "home-desktop" OR "laptop"
```

* `--when.commands`: List of subcommands to match.

Subcommands are space-separated and matched by prefix.
Expand Down
Loading