Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable rename comments handled in PR review. #31

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions vibi-dpu/src/utils/gitops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,11 @@ async fn process_blameitem(path: &str, linenum: &str, blamelines: Vec<&str>) ->
async fn process_blamelines(blamelines: &Vec<&str>, linenum: usize) -> HashMap<usize, LineItem> {
let mut linemap = HashMap::<usize, LineItem>::new();
for lnum in 0..blamelines.len() {
let ln = blamelines[lnum];
let wordvec: Vec<&str> = ln.split(" ").collect();
let commit = wordvec[0].to_string();
let (author, idx) = extract_author(&wordvec);
let timestamp = extract_timestamp(&wordvec, idx);
let blame_line = blamelines[lnum];
let blame_line_words: Vec<&str> = blame_line.split(" ").collect();
let commit = blame_line_words[0].to_string();
let (author, idx) = extract_author(&blame_line_words);
let timestamp = extract_timestamp(&blame_line_words, idx);
let lineitem = LineItem::new(author, timestamp, commit);
linemap.insert(
linenum + lnum,
Expand All @@ -444,17 +444,17 @@ async fn process_blamelines(blamelines: &Vec<&str>, linenum: usize) -> HashMap<u
return linemap;
}

fn extract_author(wordvec: &Vec<&str>) -> (String, usize) {
let mut author = wordvec[1];
fn extract_author(blame_line_words: &Vec<&str>) -> (String, usize) {
let mut author = blame_line_words[1];
let mut idx = 1;
// Check if the second value is an email address (enclosed in angle brackets)
if !author.starts_with('(') && !author.ends_with('>') {
// Shift the index to the next non-empty value
while idx < wordvec.len() && (wordvec[idx] == "" || !wordvec[idx].starts_with('(')){
while idx < blame_line_words.len() && (blame_line_words[idx] == "" || !blame_line_words[idx].starts_with('(')){
idx += 1;
}
if idx < wordvec.len() {
author = wordvec[idx];
if idx < blame_line_words.len() {
author = blame_line_words[idx];
}
} else {
// Remove the angle brackets from the email address
Expand Down