pub struct GitObservations {
pub revision: String,
pub tree: String,
pub options: StatusOptions,
pub status_identity: ArtifactIdentity,
pub tool_identity: ArtifactIdentity,
pub revision_evidence: ExecutionEvidence,
pub tree_evidence: ExecutionEvidence,
pub status_evidence: ExecutionEvidence,
}Expand description
Raw observations, without a product report or source-cleanliness guarantee.
Fields§
§revision: StringLowercase object ID returned for HEAD.
tree: StringLowercase object ID returned for the HEAD tree.
options: StatusOptionsSelected status scope, retained alongside the dirty observation.
status_identity: ArtifactIdentityRaw status byte count and SHA-256; not a canonical source-tree identity.
tool_identity: ArtifactIdentityAdmitted Git executable identity.
revision_evidence: ExecutionEvidenceOriginal bounded revision output and diagnostics.
tree_evidence: ExecutionEvidenceOriginal bounded tree output and diagnostics.
status_evidence: ExecutionEvidenceOriginal bounded status output, including arbitrary pathname bytes.
Implementations§
Source§impl GitObservations
impl GitObservations
Sourcepub const fn is_dirty(&self) -> bool
pub const fn is_dirty(&self) -> bool
Whether status reported bytes under the selected scope. Ignored files, excluded untracked files and concurrent changes are not ruled out.
Examples found in repository?
examples/inspect_git.rs (line 84)
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5 use ic_host_process::provenance::{
6 IgnoreSubmodules, StatusOptions, UntrackedFiles, capture_git,
7 };
8 use ic_host_process::tool::{AdmittedTool, ExecutionContext, OutputLimits, ToolSpec};
9
10 use std::{ffi::OsString, io, path::PathBuf, time::Duration};
11
12 let invalid = |message| io::Error::new(io::ErrorKind::InvalidInput, message);
13 let mut args = std::env::args_os().skip(1);
14 let mut required = || {
15 args.next().ok_or_else(|| invalid(
16 "usage: inspect_git TOOL SHA256 VERSION WORKDIR MAX_TOOL_BYTES MAX_STDOUT_BYTES MAX_STDERR_BYTES TIMEOUT_MS UNTRACKED SUBMODULES",
17 ))
18 };
19 let executable = PathBuf::from(required()?);
20 let digest = required()?
21 .into_string()
22 .map_err(|_| invalid("digest must be UTF-8"))?
23 .parse()?;
24 let version = required()?
25 .into_string()
26 .map_err(|_| invalid("version must be UTF-8"))?;
27 let directory = PathBuf::from(required()?);
28 let mut number = || -> Result<u64, Box<dyn std::error::Error>> {
29 Ok(required()?
30 .to_str()
31 .ok_or_else(|| invalid("limits must be UTF-8"))?
32 .parse()?)
33 };
34 let executable_bytes = number()?;
35 let limits = OutputLimits {
36 stdout: ic_host_process::tool::OutputLimit::Terminate(usize::try_from(number()?)?),
37 stderr: ic_host_process::tool::OutputLimit::Terminate(usize::try_from(number()?)?),
38 timeout: Some(Duration::from_millis(number()?)),
39 };
40 let untracked = match required()?.to_str() {
41 Some("no") => UntrackedFiles::No,
42 Some("normal") => UntrackedFiles::Normal,
43 Some("all") => UntrackedFiles::All,
44 _ => return Err(invalid("untracked must be no, normal or all").into()),
45 };
46 let ignore_submodules = match required()?.to_str() {
47 Some("none") => IgnoreSubmodules::None,
48 Some("untracked") => IgnoreSubmodules::Untracked,
49 Some("dirty") => IgnoreSubmodules::Dirty,
50 Some("all") => IgnoreSubmodules::All,
51 _ => return Err(invalid("submodules must be none, untracked, dirty or all").into()),
52 };
53 if args.next().is_some() {
54 return Err(invalid("unexpected argument").into());
55 }
56 // The example explicitly selects an empty environment; the library never
57 // chooses environment exclusions or tool/version pins for a consumer.
58 let context = ExecutionContext {
59 current_dir: &directory,
60 environment: &[],
61 };
62 let git = AdmittedTool::admit(
63 &ToolSpec {
64 executable: &executable,
65 sha256: digest,
66 executable_bytes,
67 version_arguments: &[OsString::from("--version")],
68 version_identity: &version,
69 },
70 &context,
71 limits,
72 )?;
73 let observed = capture_git(
74 &git,
75 &context,
76 StatusOptions {
77 untracked,
78 ignore_submodules,
79 },
80 limits,
81 )?;
82 println!("revision={}", observed.revision);
83 println!("tree={}", observed.tree);
84 println!("dirty={}", observed.is_dirty());
85 println!("status_bytes={}", observed.status_identity.bytes);
86 println!("status_sha256={}", observed.status_identity.sha256);
87 Ok(())
88}Trait Implementations§
Auto Trait Implementations§
impl Freeze for GitObservations
impl RefUnwindSafe for GitObservations
impl Send for GitObservations
impl Sync for GitObservations
impl Unpin for GitObservations
impl UnsafeUnpin for GitObservations
impl UnwindSafe for GitObservations
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
Mutably borrows from an owned value. Read more