MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / ensure_available

Method ensure_available

atomic-repository/src/change_source/fsmonitor.rs:52–84  ·  view source on GitHub ↗
(&self, root: &Path)

Source from the content-addressed store, hash-verified

50 }
51
52 fn ensure_available(&self, root: &Path) -> Result<(), ChangeSourceError> {
53 let output = self.git(root, &["--version"])?;
54 if output.status != 0 {
55 return Err(unavailable("git --version", &output));
56 }
57 let text = std::str::from_utf8(&output.stdout)
58 .map_err(|_| ChangeSourceError::MalformedResponse("non-UTF-8 Git version".into()))?;
59 let version = text
60 .trim()
61 .strip_prefix("git version ")
62 .ok_or_else(|| ChangeSourceError::MalformedResponse(text.trim().into()))?;
63 let parsed = parse_version(version).ok_or_else(|| {
64 ChangeSourceError::MalformedResponse(format!("invalid Git version {version}"))
65 })?;
66 if parsed < MINIMUM_GIT_VERSION {
67 return Err(ChangeSourceError::UnsupportedVersion {
68 found: version.to_owned(),
69 minimum: "2.37.0".into(),
70 });
71 }
72
73 let daemon = self.git(root, &["fsmonitor--daemon", "status"])?;
74 if daemon.status != 0 {
75 return Err(unavailable("Git builtin fsmonitor", &daemon));
76 }
77 let configured = self.git(root, &["config", "--type=bool", "--get", "core.fsmonitor"])?;
78 if configured.status != 0 || configured.stdout.as_slice() != b"true\n" {
79 return Err(ChangeSourceError::Unavailable(
80 "Git builtin fsmonitor is not enabled by core.fsmonitor=true".into(),
81 ));
82 }
83 Ok(())
84 }
85}
86
87impl ChangeSource for FsmonitorChangeSource {

Callers 1

changesMethod · 0.80

Calls 4

unavailableFunction · 0.70
parse_versionFunction · 0.70
gitMethod · 0.45
as_sliceMethod · 0.45

Tested by

no test coverage detected