pub struct GateCtx {
pub repo_root: Utf8PathBuf,
/* private fields */
}Expand description
Where a gate runs: the repository root pre-commit invoked it from, and the subject filter that bounds what it judges there.
§Subject paths and support paths
A subject path is one whose content the gate judges and which can
appear in a finding. A support path is one the gate reads to know what
to judge: the canon manifest, the known-issue records, the docs-root
resolution, the tracking registry. The filter governs subject paths.
Self::path and read_text stay open, because a filter that reached
support paths would let a project disable a gate by excluding the file
that configures it.
§Every route a subject path takes
There are three, and each passes through Self::subjects, so a gate
author cannot reach an unfiltered subject list:
- The
&[String]a gate is handed, filtered incommands::gate. walk_files, which filters before it returns.crate::gates::spec_change_is_typed, which resolves its own candidate set and filters it explicitly.
canon::every_subject_producer_is_filter_aware holds that list.
Fields§
§repo_root: Utf8PathBufThe repository root; every path a gate reads or reports is relative to it.
Implementations§
Source§impl GateCtx
impl GateCtx
Sourcepub fn new(repo_root: impl Into<Utf8PathBuf>) -> Self
pub fn new(repo_root: impl Into<Utf8PathBuf>) -> Self
A context rooted at the given repository, judging everything.
This is the shape every test and every internal caller wants. The
command path uses Self::with_filter.
Sourcepub fn with_filter(
repo_root: impl Into<Utf8PathBuf>,
filter: PathFilter,
) -> Self
pub fn with_filter( repo_root: impl Into<Utf8PathBuf>, filter: PathFilter, ) -> Self
A context whose gate judges only what the filter admits.
Sourcepub fn path(&self, relative: impl AsRef<Utf8Path>) -> Utf8PathBuf
pub fn path(&self, relative: impl AsRef<Utf8Path>) -> Utf8PathBuf
Resolve a repository-relative path for reading.
Deliberately unfiltered: a gate reads its support files through here.
Sourcepub fn subjects<P: AsRef<Utf8Path>>(
&self,
candidates: impl IntoIterator<Item = P>,
) -> Vec<P>
pub fn subjects<P: AsRef<Utf8Path>>( &self, candidates: impl IntoIterator<Item = P>, ) -> Vec<P>
The subset of candidates this gate judges.
Every subject path pre-commit or an operator hands a gate comes through here, and the registry whitelist binds.
Sourcepub fn retained<P: AsRef<Utf8Path>>(
&self,
candidates: impl IntoIterator<Item = P>,
) -> Vec<P>
pub fn retained<P: AsRef<Utf8Path>>( &self, candidates: impl IntoIterator<Item = P>, ) -> Vec<P>
The subset of candidates this gate’s exclusions leave.
For a subject set the gate discovered itself. See
PathFilter::retains.
Sourcepub const fn filter(&self) -> &PathFilter
pub const fn filter(&self) -> &PathFilter
The filter itself, for --explain and for the renderer.