Struct determinator::Determinator [−][src]
Determine target dependencies from changed files and packages in a workspace.
For more about how the determinator works, see the crate-level documentation.
This struct has two lifetime parameters:
'g
stands for the lifetime of the new graph. TheDeterminatorSet
will be bound to this lifetime.'a
is the lifetime of the old graph, Cargo options, and changed paths. TheDeterminatorSet
will not be bound to this lifetime.
Implementations
impl<'g, 'a> Determinator<'g, 'a>
[src]
pub fn new(old: &'a PackageGraph, new: &'g PackageGraph) -> Self
[src]
Creates a new instance of Determinator
with old and new package graphs.
pub fn add_changed_paths(
&mut self,
paths: impl IntoIterator<Item = &'a Path>
) -> &mut Self
[src]
&mut self,
paths: impl IntoIterator<Item = &'a Path>
) -> &mut Self
Adds a list of changed paths. This list is used as a source of information for the determinator.
This should consist of paths that are changed since the base revision, and should use the
canonical separator for the platform (e.g. /
on Unix platforms and \
on Windows).
Paths0
in this crate provides a convenient way to handle null-separated
paths as produced by source control systems.
Should you include untracked and ignored files?
For comparisons against the working directory, one may or may not wish to include untracked files. A few points to consider:
- If your code uses a library like
datatest
, simply creating a file in the right place is enough to add a new test. If untracked files are not included, the user may have to rungit add
before the determinator picks the change up. - On the other hand, if a user wishes to include a new test in their PR, they're going to
have to run
git add
at some point anyway. - Some users may have untracked files lying around in their repository for long periods of time, and those files may cause false positives.
- Git makes it surprisingly hard to list out untracked files, requiring
git status --porcelain -z
with some additional filtering on top to do so.git diff
doesn't have an option to list untracked files. - This is generally moot in CI, since those workflows will likely be comparing against a commit.
- In most cases, ignored files should not be considered by the determinator, since they don't affect CI builds.
On balance, only considering tracked files appears to be the right approach for most situations.
pub fn match_path(
&self,
path: impl AsRef<Path>,
match_cb: impl FnMut(&'g PackageId)
) -> PathMatch
[src]
&self,
path: impl AsRef<Path>,
match_cb: impl FnMut(&'g PackageId)
) -> PathMatch
Returns what would happen if a given path was added to the changed set.
This does not add any path to the changed set, but indicates what would happen if a path is added.
This method may be used to ensure that all paths in a repository are covered by at least one rule if they don't match a package.
match_cb
is called for all package IDs that the path matches.
pub fn set_rules(
&mut self,
rules: &DeterminatorRules
) -> Result<&mut Self, RulesError>
[src]
&mut self,
rules: &DeterminatorRules
) -> Result<&mut Self, RulesError>
Processes and configures determinator rules.
Returns an error if the rules were invalid in some way.
pub fn set_cargo_options(
&mut self,
cargo_options: &'a CargoOptions<'a>
) -> &mut Self
[src]
&mut self,
cargo_options: &'a CargoOptions<'a>
) -> &mut Self
Configures Cargo options.
These options are used to determine if the build for a particular package has changed.
If no options are specified, the default CargoOptions
, as specified by
CargoOptions::new
, are used, with one exception: dev-dependencies are built by default.
pub fn default_cargo_options() -> CargoOptions<'static>
[src]
Returns the default Cargo options used by the determinator.
These are the same as the defaults returned by CargoOptions::new
,
except:
- dev-dependencies are enabled
- the host and target platforms are set to the current platform
pub fn set_features_only<'b>(
&mut self,
workspace_names: impl IntoIterator<Item = &'b str>,
features: StandardFeatures
) -> Result<&mut Self, Error>
[src]
&mut self,
workspace_names: impl IntoIterator<Item = &'b str>,
features: StandardFeatures
) -> Result<&mut Self, Error>
Configures features-only packages that are used in build simulations.
The packages and features will be used for feature unification. This is useful for pseudo-packages or workspace-hack packages, including those generated by tools like Hakari.
For more about features_only
, see the documentation for CargoSet::new
.
The package names are expected to be present in the new graph, but may not be present in the
old PackageGraph
.
- If a package name isn't in the new graph, this method returns an error.
- If a package name isn't in the old graph, it is ignored.
pub fn compute(&self) -> DeterminatorSet<'g>
[src]
Uses the old and new sets and the list of changed files to compute the list of projects that is affected.
Trait Implementations
impl<'g, 'a> Clone for Determinator<'g, 'a>
[src]
fn clone(&self) -> Determinator<'g, 'a>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'g, 'a> Debug for Determinator<'g, 'a>
[src]
Auto Trait Implementations
impl<'g, 'a> !RefUnwindSafe for Determinator<'g, 'a>
[src]
impl<'g, 'a> Send for Determinator<'g, 'a>
[src]
impl<'g, 'a> Sync for Determinator<'g, 'a>
[src]
impl<'g, 'a> Unpin for Determinator<'g, 'a>
[src]
impl<'g, 'a> !UnwindSafe for Determinator<'g, 'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T> DefaultFeatures<'a> for T where
T: 'a + Clone + Send + Sync,
T: 'a + Clone + Send + Sync,
pub fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a> + 'a, Global>
pub fn self_address_mut(&mut self) -> *mut ()
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<'a, T> NonSyncFeatures<'a> for T where
T: 'a + Clone,
T: 'a + Clone,
pub fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a> + 'a, Global>
pub fn self_address_mut(&mut self) -> *mut ()
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> SafeBorrow<T> for T where
T: ?Sized,
T: ?Sized,
pub fn borrow_replacement(ptr: &T) -> &T
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,