Collect up to `limit` recent changes on `view`, newest first, as `(short_hash, message)` pairs for the no-pending-changes hint. Best-effort: any failure to read history yields an empty list, which degrades the hint rather than the diff.
(
&self,
repo: &Repository,
view: &str,
limit: usize,
)
| 147 | /// Best-effort: any failure to read history yields an empty list, which |
| 148 | /// degrades the hint rather than the diff. |
| 149 | fn recent_view_changes( |
| 150 | &self, |
| 151 | repo: &Repository, |
| 152 | view: &str, |
| 153 | limit: usize, |
| 154 | ) -> Vec<(String, String)> { |
| 155 | use atomic_repository::history::HistoryOptions; |
| 156 | |
| 157 | let options = HistoryOptions::new() |
| 158 | .view(view.to_string()) |
| 159 | .limit(limit) |
| 160 | .load_headers(true) |
| 161 | // A draft view's own log is usually empty right after it forks, |
| 162 | // but it still inherits everything from its ancestors — and those |
| 163 | // changes are diffable here. Without this the hint would claim |
| 164 | // the view has no recorded changes when it plainly does. |
| 165 | .include_inherited(true); |
| 166 | |
| 167 | let Ok(entries) = repo.reverse_log(options) else { |
| 168 | return Vec::new(); |
| 169 | }; |
| 170 | |
| 171 | entries |
| 172 | .into_iter() |
| 173 | .map(|entry| { |
| 174 | let base32 = entry.hash.to_base32(); |
| 175 | let short_hash = base32[..DEFAULT_HASH_LENGTH.min(base32.len())].to_string(); |
| 176 | let message = entry |
| 177 | .header |
| 178 | .map(|h| h.message) |
| 179 | .filter(|m| !m.trim().is_empty()) |
| 180 | .unwrap_or_else(|| "(no message)".to_string()); |
| 181 | (short_hash, message) |
| 182 | }) |
| 183 | .collect() |
| 184 | } |
| 185 | |
| 186 | /// Check whether a repository-relative path passes the positional |
| 187 | /// file filter (`atomic diff --change <hash> <file>...`). |
no test coverage detected