Skip to content

Commit

Permalink
Merge pull request #66 from Alokit-Innovations/tr/zero_deletion_bugfix
Browse files Browse the repository at this point in the history
Test Tr/zero deletion bugfix
  • Loading branch information
tapishr authored Nov 1, 2023
2 parents cf2e6db + 509937b commit ea78255
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
25 changes: 2 additions & 23 deletions vibi-dpu/src/pubsub/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use std::collections::HashMap;
use std::collections::VecDeque;
use tokio::task;
use tonic::Code;
use crate::db::prs::process_and_update_pr_if_different;
use crate::core::{setup::handle_install_bitbucket, review::process_review};

#[derive(Debug, Deserialize)]
struct InstallCallback {
Expand Down Expand Up @@ -64,29 +66,6 @@ async fn process_message(attributes: &HashMap<String, String>, data_bytes: &Vec<
};
}

async fn process_install_callback(data_bytes: &[u8]) {
println!("Processing install callback message");
let msg_data_res = serde_json::from_slice::<InstallCallback>(data_bytes);
if msg_data_res.is_err() {
eprintln!("Error deserializing install callback: {:?}", msg_data_res);
return;
}
let data = msg_data_res.expect("msg_data not found");
if data.repository_provider == ProviderEnum::Github.to_string().to_lowercase() {
let code_async = data.installation_code.clone();
task::spawn(async move {
handle_install_github(&code_async).await;
println!("Processed install callback message");
});
}
if data.repository_provider == ProviderEnum::Bitbucket.to_string().to_lowercase() {
let code_async = data.installation_code.clone();
task::spawn(async move {
handle_install_bitbucket(&code_async).await;
println!("Processed install callback message");
});
}
}

pub async fn get_pubsub_client_config(keypath: &str) -> ClientConfig {
let credfile = CredentialsFile::new_from_file(keypath.to_string())
Expand Down
13 changes: 7 additions & 6 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 < 0) {
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

0 comments on commit ea78255

Please sign in to comment.