Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ To run Vibi-DPU locally:

1. Generate public url using ngrok - `ngrok http 3000`. We will run our next server locally on port 3000 in later steps.
2. Paste this in OAuth consumers in callback_url field.
3. Clone [team-monitor-webiste](https://github.com/Alokit-Innovations/team-monitor-website/) locally.
4. Paste the client id and secret in team-monitor-wesite in .env.local in root directory. Also use them in the docker command below.
3. Clone [vibinex-server](https://github.com/Alokit-Innovations/vibinex-server/) locally.
4. Paste the client id and secret in vibinex-server in .env.local in root directory. Also use them in the docker command below.
5. Fire up cloud sql proxy - `./cloud-sql-proxy --port 5432 vibi-test-394606:asia-south1:test-db`
6. Change url in team-monitor-website in .env.local - `NEXTAUTH_URL=https://example.ngrok-free.app`
7. Start team-monitor-website - `npm run dev`
6. Change url in vibinex-server in .env.local - `NEXTAUTH_URL=https://example.ngrok-free.app`
7. Start vibinex-server - `npm run dev`
8. Build vibi-dpu, go to vibi-dpu/vibi-dpu and run - `cargo build`
9. Go up to the root directory of vibi-dpu - `cd ../`
10. **Build the Docker image**: In the root directory of the project, run the following command to build a Docker image with the name "dpu".
Expand Down Expand Up @@ -50,4 +50,4 @@ We welcome contributions from the community! Please read our contributing guidel

## License

This project is licensed under the terms of the GNU-GPLv3.
This project is licensed under the terms of the GNU-GPLv3.
35 changes: 26 additions & 9 deletions vibi-dpu/src/utils/gitops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,22 @@ pub fn get_excluded_files(review: &Review) -> Option<(Vec<StatItem>, Vec<StatIte

fn process_statoutput(statstr: &str) -> Option<(Vec<StatItem>, Vec<StatItem>)>{
let statvec = process_statitems(statstr);
let mut bigfiles = Vec::<StatItem>::new();
let mut smallfiles = Vec::<StatItem>::new();
let mut excluded_files = Vec::<StatItem>::new();
let mut filtered_files = Vec::<StatItem>::new();
let line_threshold = 500;
for item in statvec {
// logic for exclusion
if (item.additions > line_threshold) ||
(item.deletions > line_threshold) ||
(item.additions + item.deletions > line_threshold) {
bigfiles.push(item);
(item.additions + item.deletions > line_threshold) ||
(item.deletions < 1) {
excluded_files.push(item);
}
else {
smallfiles.push(item);
filtered_files.push(item);
}
}
return Some((bigfiles, smallfiles));
return Some((excluded_files, filtered_files));
}

fn generate_statitem(statitems: &Vec<&str>) -> StatItem {
Expand Down Expand Up @@ -222,8 +223,8 @@ pub fn generate_diff(review: &Review, smallfiles: &Vec<StatItem>) -> HashMap<Str
let filepath = item.filepath.as_str();
let params = vec![
"diff".to_string(),
format!("{prev_commit}:{filepath}"),
format!("{curr_commit}:{filepath}"),
format!("{prev_commit}...{curr_commit}"),
format!("-- {filepath}"),
"-U0".to_string(),
];
let output_res = Command::new("git").args(&params)
Expand Down Expand Up @@ -253,7 +254,9 @@ fn process_diff(filepath: &str, diff: &str, linemap: &mut HashMap<String, Vec<St
let mut limiterpos = Vec::new();
let delimitter = "@@";
for (idx, _) in diff.match_indices(delimitter) {
limiterpos.push(idx);
if has_deletions(&diff[idx..]) {
limiterpos.push(idx);
}
}
let mut idx: usize = 0;
let len = limiterpos.len();
Expand Down Expand Up @@ -320,6 +323,20 @@ fn process_diff(filepath: &str, diff: &str, linemap: &mut HashMap<String, Vec<St
return linemap.to_owned();
}

fn has_deletions(hunk: &str) -> bool {
// Split the hunk into lines
let lines = hunk.split('\n').collect::<Vec<&str>>();

// Iterate through the lines to check for deletions
for line in lines.iter() {
if line.starts_with('-') && !line.starts_with("---") {
return true;
}
}

return false;
}

pub fn process_diffmap(diffmap: &HashMap<String, String>) -> HashMap<String, Vec<String>> {
let mut linemap: HashMap<String, Vec<String>> = HashMap::new();
for (filepath, diff) in diffmap {
Expand Down