Struct auto_owners::OwnersDb
source · pub(crate) struct OwnersDb {
pub(crate) projects: Vec<ProjectMetadata>,
pub(crate) owners_path_cache: BTreeMap<String, Utf8PathBuf>,
pub(crate) rust_metadata: Option<PathBuf>,
pub(crate) overrides: BTreeMap<String, Vec<Utf8PathBuf>>,
pub(crate) dry_run: bool,
pub(crate) update_strategy: UpdateStrategy,
pub(crate) gn_bin: PathBuf,
pub(crate) out_dir: PathBuf,
}
Fields§
§projects: Vec<ProjectMetadata>
metadata about projects
owners_path_cache: BTreeMap<String, Utf8PathBuf>
cache of OWNERS file paths, indexed by target name. Holds the targets for which the corresponding OWNERS file path is known; cached to avoid probing the filesystem
rust_metadata: Option<PathBuf>
path to the JSON metadata produced by cargo-gnaw
overrides: BTreeMap<String, Vec<Utf8PathBuf>>
explicit lists of OWNERS files to include instead of inferring, indexed by project name
dry_run: bool
if set, print update results instead of updating OWNERS file
update_strategy: UpdateStrategy
§gn_bin: PathBuf
§out_dir: PathBuf
Implementations§
source§impl OwnersDb
impl OwnersDb
pub(crate) fn new( rust_metadata: Option<PathBuf>, integration_manifest: Option<PathBuf>, overrides: Utf8PathBuf, gn_bin: PathBuf, out_dir: PathBuf, update_strategy: UpdateStrategy, projects_path: Option<String>, dry_run: bool ) -> Result<Self>
sourcepub(crate) fn update_all_files(&self) -> Result<()>
pub(crate) fn update_all_files(&self) -> Result<()>
Update all OWNERS files for all projects.
sourcepub(crate) fn update_owners_file<W: Write>(
&self,
metadata: &ProjectMetadata,
output_buffer: &mut W
) -> Result<()>
pub(crate) fn update_owners_file<W: Write>( &self, metadata: &ProjectMetadata, output_buffer: &mut W ) -> Result<()>
Update the OWNERS file for a single 3p project.
pub(crate) fn compute_owners_file( &self, metadata: &ProjectMetadata ) -> Result<OwnersFile>
sourcepub(crate) fn owners_files_from_reverse_deps(
&self,
metadata: &ProjectMetadata
) -> Result<OwnersFile>
pub(crate) fn owners_files_from_reverse_deps( &self, metadata: &ProjectMetadata ) -> Result<OwnersFile>
Run gn refs
for the project’s GN target(s) and find the OWNERS files that correspond to its
reverse deps.
For Rust projects, cargo-gnaw metadata encodes version-unambiguous GN targets like
//third_party/rust_crates:foo-v1_0_0
but we discourage the use of those targets
throughout the tree. To find dependencies from in-house code we need to also get reverse
deps for the equivalent target without the version, e.g. //third_party/rust_crates:foo
.
sourcepub(crate) fn reverse_deps(&self, target: &str) -> Result<BTreeSet<String>>
pub(crate) fn reverse_deps(&self, target: &str) -> Result<BTreeSet<String>>
Run gn refs $OUT_DIR $GN_TARGET
and return a list of GN targets which depend on the
target.
sourcepub(crate) fn owners_file_for_gn_target(
&self,
target: &str
) -> Result<Utf8PathBuf>
pub(crate) fn owners_file_for_gn_target( &self, target: &str ) -> Result<Utf8PathBuf>
Given a GN target, find the most likely path for its corresponding OWNERS file.