(repo: &gix::Repository, selected_columns: &[String])
| 110 | } |
| 111 | |
| 112 | fn select_commits(repo: &gix::Repository, selected_columns: &[String]) -> Result<Vec<Row>, String> { |
| 113 | let head_id = repo.head_id(); |
| 114 | if let Err(error) = head_id { |
| 115 | return Err(error.to_string()); |
| 116 | } |
| 117 | |
| 118 | let repo_path = repo.path().to_str().unwrap(); |
| 119 | let walker = head_id.unwrap().ancestors().all().unwrap(); |
| 120 | let mut rows: Vec<Row> = vec![]; |
| 121 | |
| 122 | for commit_info in walker { |
| 123 | let commit_info = commit_info.unwrap(); |
| 124 | let commit = repo.find_object(commit_info.id).unwrap().into_commit(); |
| 125 | let commit = commit.decode().unwrap(); |
| 126 | |
| 127 | let mut values: Vec<Box<dyn Value>> = Vec::with_capacity(selected_columns.len()); |
| 128 | for column_name in selected_columns { |
| 129 | if column_name == "commit_id" { |
| 130 | values.push(Box::new(TextValue::new(commit_info.id.to_string()))); |
| 131 | continue; |
| 132 | } |
| 133 | |
| 134 | if column_name == "author_name" { |
| 135 | if let Ok(commit_author) = commit.author() { |
| 136 | values.push(Box::new(TextValue::new(commit_author.name.to_string()))); |
| 137 | continue; |
| 138 | } |
| 139 | values.push(Box::new(TextValue::empty())); |
| 140 | continue; |
| 141 | } |
| 142 | |
| 143 | if column_name == "author_email" { |
| 144 | if let Ok(commit_author) = commit.author() { |
| 145 | values.push(Box::new(TextValue::new(commit_author.email.to_string()))); |
| 146 | continue; |
| 147 | } |
| 148 | values.push(Box::new(TextValue::empty())); |
| 149 | continue; |
| 150 | } |
| 151 | |
| 152 | if column_name == "committer_name" { |
| 153 | if let Ok(commit_committer) = commit.committer() { |
| 154 | values.push(Box::new(TextValue::new(commit_committer.name.to_string()))); |
| 155 | continue; |
| 156 | } |
| 157 | values.push(Box::new(TextValue::empty())); |
| 158 | continue; |
| 159 | } |
| 160 | |
| 161 | if column_name == "committer_email" { |
| 162 | if let Ok(commit_committer) = commit.committer() { |
| 163 | values.push(Box::new(TextValue::new(commit_committer.email.to_string()))); |
| 164 | continue; |
| 165 | } |
| 166 | values.push(Box::new(TextValue::empty())); |
| 167 | continue; |
| 168 | } |
| 169 |
no test coverage detected
searching dependent graphs…