-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: resolve conditional config scopes
This is an alternative way to achieve includeIf of Git without adding "include" directive. Conditional include (or include in general) is a bit trickier to implement than loading all files and filtering the contents. Closes jj-vcs#616
- Loading branch information
Showing
7 changed files
with
214 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1219,3 +1219,27 @@ To load an entire TOML document, use `--config-file`: | |
```shell | ||
jj --config-file=extra-config.toml log | ||
``` | ||
|
||
### Conditional variables | ||
|
||
You can conditionally enable config variables by using `--when` and | ||
`[[--scope]]` tables. Variables defined in `[[--scope]]` tables are expanded to | ||
the root table. `--when` specifies the condition to enable the scope table. | ||
|
||
```toml | ||
[user] | ||
name = "YOUR NAME" | ||
email = "[email protected]" | ||
|
||
# override user.email if the repository is located under ~/oss | ||
[[--scope]] | ||
--when.repositories = ["~/oss"] | ||
[--scope.user] | ||
email = "[email protected]" | ||
``` | ||
|
||
Condition keys: | ||
|
||
* `--when.repositories`: List of paths to match the repository path prefix. | ||
|
||
If no conditions are specified, the table is always enabled. |