Reads commits on one span target's branch within its (gap-widened) window via `git log`. Returns an empty list on any error so the sweep simply attributes nothing for that target rather than failing. The worktree value is a recorded span path; if it no longer exists on disk the scan yields nothing.
(
target: &git_correlation::SpanScanTarget,
gap_secs: i64,
)
| 121 | /// is a recorded span path; if it no longer exists on disk the scan yields |
| 122 | /// nothing. |
| 123 | fn git_scan_commits( |
| 124 | target: &git_correlation::SpanScanTarget, |
| 125 | gap_secs: i64, |
| 126 | ) -> Vec<git_correlation::ScannedCommit> { |
| 127 | let worktree = Path::new(&target.worktree); |
| 128 | if !worktree.is_dir() { |
| 129 | return Vec::new(); |
| 130 | } |
| 131 | let since = target.window_start.saturating_sub(gap_secs); |
| 132 | let until = target.window_end.saturating_add(gap_secs); |
| 133 | let mut command = std::process::Command::new(crate::git::git_program()); |
| 134 | command |
| 135 | .current_dir(worktree) |
| 136 | .arg("log") |
| 137 | .arg(format!("--since={since}")) |
| 138 | .arg(format!("--until={until}")) |
| 139 | .arg("--pretty=format:%H %ct"); |
| 140 | // Scope to the recorded branch when known; detached-HEAD spans scan HEAD. |
| 141 | match target.branch.as_deref() { |
| 142 | Some(branch) if !branch.is_empty() => { |
| 143 | command.arg(branch); |
| 144 | } |
| 145 | _ => {} |
| 146 | } |
| 147 | let Ok(output) = command.output() else { |
| 148 | return Vec::new(); |
| 149 | }; |
| 150 | if !output.status.success() { |
| 151 | return Vec::new(); |
| 152 | } |
| 153 | parse_git_log_commits(&String::from_utf8_lossy(&output.stdout)) |
| 154 | } |
| 155 | |
| 156 | /// Parses `%H %ct` lines from `git log` into scanned commits, skipping |
| 157 | /// malformed rows. |
no test coverage detected