pub struct RepoConfigLayers { /* private fields */ }Expand description
A repository’s configuration as the two files that can contribute to it.
The project file wins every scalar key it names, and the personal file answers the rest. That is the inverse of the usual local-overrides-committed convention, and deliberately so: the settings here are the ones a project decides, and a team that has written down “this repository is not worth pruning” wants that to survive a teammate’s stale personal file rather than lose to it.
“Names a key” means the key is literally in the file. A project file silent on
ignore does not overrule the personal one with serde’s false, because a default
filled in by the deserializer is not something anybody wrote down.
prunable.directories is the one thing that unions instead of winning. It is a list
of separate declarations rather than a single decided value, so there is nothing for
one file to win: “the team says this cache is rebuildable” and “so is this one on my
machine” are both true at once, and a rule that let the committed file silence the
personal list would delete somebody’s own declaration the day their team wrote their
first one.
Nothing here widens what a repository can ask for. Both files deserialize into the
same PerRepoConfig, so the two settings the type deliberately does not carry —
allow_manifest_rewrite and post_prune_command — are still absent from both, and
every field that is present is either display-only or scope-shaping. A committed
.devprune.json has had exactly this reach since 1.0.0, since the .git/info/exclude
entry is local to one clone and excludes nothing already tracked; the shared file
makes that reach a named, documented file instead of an accident.
Implementations§
Source§impl RepoConfigLayers
impl RepoConfigLayers
Sourcepub fn load(repo_path: &Path) -> Result<Self, String>
pub fn load(repo_path: &Path) -> Result<Self, String>
Read both files. Err if either exists and does not parse.
Sourcepub fn effective(&self) -> Option<PerRepoConfig>
pub fn effective(&self) -> Option<PerRepoConfig>
The merged configuration, or None when the repository has neither file.
None rather than the defaults, because every caller of this treats “no config”
and “a config that happens to match the defaults” as the same thing to act on but
not the same thing to report.
Sourcepub fn project_config(&self) -> Option<&PerRepoConfig>
pub fn project_config(&self) -> Option<&PerRepoConfig>
The committed file as it stands, before the personal one fills any gaps in.
Sourcepub fn personal_config(&self) -> Option<&PerRepoConfig>
pub fn personal_config(&self) -> Option<&PerRepoConfig>
The personal file as it stands, before the project one overrules any of it.
Sourcepub fn rows(&self) -> Vec<(&'static str, String, ConfigSource)>
pub fn rows(&self) -> Vec<(&'static str, String, ConfigSource)>
Which file each setting’s effective value came from.
This is what gets shown instead of copying the project file’s values into
.devprune.json as a visible “mirror”. A second copy of a value is a second copy
free to drift from the first, and the question somebody actually has in front of
two config files is not “what does each say” but “which one won”.
Sourcepub fn source_of(&self, key: &str) -> ConfigSource
pub fn source_of(&self, key: &str) -> ConfigSource
Which file spelled this key out, in precedence order.
Auto Trait Implementations§
impl Freeze for RepoConfigLayers
impl RefUnwindSafe for RepoConfigLayers
impl Send for RepoConfigLayers
impl Sync for RepoConfigLayers
impl Unpin for RepoConfigLayers
impl UnsafeUnpin for RepoConfigLayers
impl UnwindSafe for RepoConfigLayers
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more