(&self, root: &Path)
| 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 | |
| 87 | impl ChangeSource for FsmonitorChangeSource { |
no test coverage detected