Skip to content

Commit 04b0b3e

Browse files
committed
Handling optional commit author and committer
1 parent e77b943 commit 04b0b3e

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

src/gitql/gitql_data_provider.rs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,38 @@ fn select_commits(repo: &gix::Repository, selected_columns: &[String]) -> Result
132132
}
133133

134134
if column_name == "author_name" {
135-
let author_name = commit.author().unwrap().name.to_string();
136-
values.push(Box::new(TextValue::new(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()));
137140
continue;
138141
}
139142

140143
if column_name == "author_email" {
141-
let author_email = commit.author().unwrap().email.to_string();
142-
values.push(Box::new(TextValue::new(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()));
143149
continue;
144150
}
145151

146152
if column_name == "committer_name" {
147-
let committer_name = commit.committer().unwrap().name.to_string();
148-
values.push(Box::new(TextValue::new(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()));
149158
continue;
150159
}
151160

152161
if column_name == "committer_email" {
153-
let committer_email = commit.committer().unwrap().email.to_string();
154-
values.push(Box::new(TextValue::new(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()));
155167
continue;
156168
}
157169

@@ -350,14 +362,20 @@ fn select_diffs(repo: &gix::Repository, selected_columns: &[String]) -> Result<V
350362
}
351363

352364
if column_name == "author_name" {
353-
let author_name = commit_ref.author().unwrap().name.to_string();
354-
values.push(Box::new(TextValue::new(author_name)));
365+
if let Ok(commit_author) = commit.author() {
366+
values.push(Box::new(TextValue::new(commit_author.name.to_string())));
367+
continue;
368+
}
369+
values.push(Box::new(TextValue::empty()));
355370
continue;
356371
}
357372

358373
if column_name == "author_email" {
359-
let author_email = commit_ref.author().unwrap().email.to_string();
360-
values.push(Box::new(TextValue::new(author_email)));
374+
if let Ok(commit_author) = commit.author() {
375+
values.push(Box::new(TextValue::new(commit_author.email.to_string())));
376+
continue;
377+
}
378+
values.push(Box::new(TextValue::empty()));
361379
continue;
362380
}
363381

0 commit comments

Comments
 (0)