fsmonitor: move default settings to config/misc.toml
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

This commit is contained in:
Yuya Nishihara 2024-12-24 10:53:58 +09:00
parent 9b60a9df90
commit e5361c6cc0
2 changed files with 22 additions and 23 deletions

View file

@ -1,3 +1,9 @@
[core]
fsmonitor = "none"
[core.watchman]
register_snapshot_trigger = false
[debug]
# commit-timestamp = <now>
# operation-timestamp = <now>

View file

@ -25,7 +25,6 @@
use std::path::PathBuf;
use crate::config::ConfigGetError;
use crate::config::ConfigGetResultExt as _;
use crate::settings::UserSettings;
/// Config for Watchman filesystem monitor (<https://facebook.github.io/watchman/>).
@ -59,28 +58,22 @@ impl FsmonitorSettings {
/// Creates an `FsmonitorSettings` from a `config`.
pub fn from_settings(settings: &UserSettings) -> Result<FsmonitorSettings, ConfigGetError> {
let name = "core.fsmonitor";
match settings.get_string(name) {
Ok(s) => match s.as_str() {
"watchman" => Ok(Self::Watchman(WatchmanConfig {
register_trigger: settings
.get_bool("core.watchman.register_snapshot_trigger")
.optional()?
.unwrap_or_default(),
})),
"test" => Err(ConfigGetError::Type {
name: name.to_owned(),
error: "Cannot use test fsmonitor in real repository".into(),
source_path: None,
}),
"none" => Ok(Self::None),
other => Err(ConfigGetError::Type {
name: name.to_owned(),
error: format!("Unknown fsmonitor kind: {other}").into(),
source_path: None,
}),
},
Err(ConfigGetError::NotFound { .. }) => Ok(Self::None),
Err(err) => Err(err),
match settings.get_string(name)?.as_ref() {
"watchman" => Ok(Self::Watchman(WatchmanConfig {
// TODO: rename to "register-snapshot-trigger" for consistency?
register_trigger: settings.get_bool("core.watchman.register_snapshot_trigger")?,
})),
"test" => Err(ConfigGetError::Type {
name: name.to_owned(),
error: "Cannot use test fsmonitor in real repository".into(),
source_path: None,
}),
"none" => Ok(Self::None),
other => Err(ConfigGetError::Type {
name: name.to_owned(),
error: format!("Unknown fsmonitor kind: {other}").into(),
source_path: None,
}),
}
}
}