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

Method changes

atomic-repository/src/change_source/fsmonitor.rs:88–141  ·  view source on GitHub ↗
(
        &self,
        request: ChangeSourceRequest<'_>,
    )

Source from the content-addressed store, hash-verified

86
87impl ChangeSource for FsmonitorChangeSource {
88 fn changes(
89 &self,
90 request: ChangeSourceRequest<'_>,
91 ) -> Result<ChangeSourceResult, ChangeSourceError> {
92 validate_token(request.previous_token)?;
93 self.ensure_available(request.root)?;
94 let output = self.git(
95 request.root,
96 &[
97 "status",
98 "--porcelain=v2",
99 "-z",
100 "--untracked-files=all",
101 "--ignore-submodules=none",
102 ],
103 )?;
104 if output.status != 0 {
105 return Err(unavailable("Git status query", &output));
106 }
107
108 let tracked: BTreeSet<_> = request.tracked_paths.iter().cloned().collect();
109 let raw = parse_porcelain_v2(&output.stdout, self.max_candidates)?;
110 let mut paths = BTreeSet::new();
111 for bytes in raw {
112 let path =
113 RepoPath::new(bytes).map_err(|error| ChangeSourceError::Path(error.to_string()))?;
114 if tracked.contains(&path) {
115 paths.insert(path);
116 }
117 }
118 let mut candidates = Vec::with_capacity(paths.len());
119 for path in paths {
120 candidates.push(observe_candidate(
121 request.root,
122 path,
123 ChangeCandidateReason::Explicit,
124 )?);
125 }
126 Ok(ChangeSourceResult {
127 root: request.root.to_path_buf(),
128 source: super::ChangeSourceKind::Fsmonitor,
129 fallback_source: None,
130 token: output_token(&output.stdout),
131 complete: false,
132 fallback: None,
133 stats: ChangeSourceStats {
134 tracked_paths: request.tracked_paths.len(),
135 candidates: candidates.len(),
136 metadata_reads: candidates.len(),
137 ..ChangeSourceStats::default()
138 },
139 candidates,
140 })
141 }
142}
143
144fn validate_token(token: Option<&ChangeSourceToken>) -> Result<(), ChangeSourceError> {

Calls 13

parse_porcelain_v2Function · 0.85
observe_candidateFunction · 0.85
output_tokenFunction · 0.85
ensure_availableMethod · 0.80
validate_tokenFunction · 0.70
unavailableFunction · 0.70
gitMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45
lenMethod · 0.45

Tested by 1