(
repo: &gix::Repository,
selected_columns: &[String],
)
| 207 | } |
| 208 | |
| 209 | fn select_branches( |
| 210 | repo: &gix::Repository, |
| 211 | selected_columns: &[String], |
| 212 | ) -> Result<Vec<Row>, String> { |
| 213 | let mut rows: Vec<Row> = vec![]; |
| 214 | |
| 215 | let repo_path = repo.path().to_str().unwrap(); |
| 216 | let platform = repo.references().unwrap(); |
| 217 | let local_branches = platform.local_branches().unwrap(); |
| 218 | let remote_branches = platform.remote_branches().unwrap(); |
| 219 | let local_and_remote_branches = local_branches.chain(remote_branches); |
| 220 | let head_ref_result = repo.head_ref(); |
| 221 | if let Err(error) = head_ref_result { |
| 222 | return Err(error.to_string()); |
| 223 | } |
| 224 | |
| 225 | let head_ref_option = head_ref_result.unwrap(); |
| 226 | if head_ref_option.is_none() { |
| 227 | return Ok(rows); |
| 228 | } |
| 229 | |
| 230 | let head_ref = head_ref_option.unwrap(); |
| 231 | for mut branch in local_and_remote_branches.flatten() { |
| 232 | let mut values: Vec<Box<dyn Value>> = Vec::with_capacity(selected_columns.len()); |
| 233 | |
| 234 | for column_name in selected_columns { |
| 235 | if column_name == "name" { |
| 236 | let branch_name = branch.name().as_bstr().to_string(); |
| 237 | values.push(Box::new(TextValue::new(branch_name))); |
| 238 | continue; |
| 239 | } |
| 240 | |
| 241 | if column_name == "commit_count" { |
| 242 | if let Some(id) = branch.try_id() |
| 243 | && let Ok(walker) = id.ancestors().all() |
| 244 | { |
| 245 | values.push(Box::new(IntValue::new(walker.count() as i64))); |
| 246 | continue; |
| 247 | } |
| 248 | values.push(Box::new(IntValue::new_zero())); |
| 249 | continue; |
| 250 | } |
| 251 | |
| 252 | if column_name == "updated" { |
| 253 | if let Ok(top_commit_id) = branch.peel_to_id() { |
| 254 | let walker = top_commit_id.ancestors().all().unwrap(); |
| 255 | if let Some(commit_info) = walker.into_iter().next() { |
| 256 | let commit_info = commit_info.unwrap(); |
| 257 | if let Some(commit_timestamp) = commit_info.commit_time { |
| 258 | values.push(Box::new(DateTimeValue::new(commit_timestamp))); |
| 259 | continue; |
| 260 | } |
| 261 | |
| 262 | let commit = repo.find_object(commit_info.id).unwrap().into_commit(); |
| 263 | let commit = commit.decode().unwrap(); |
| 264 | values.push(Box::new(DateTimeValue::new(commit.time().unwrap().seconds))); |
| 265 | continue; |
| 266 | } |
no test coverage detected
searching dependent graphs…