Skip to content

Commit

Permalink
chore(structured_doc): only fetch pull diff when changed lines fewer …
Browse files Browse the repository at this point in the history
…than 100K (#3488)

Signed-off-by: Wei Zhang <[email protected]>
  • Loading branch information
zwpaper authored Nov 28, 2024
1 parent c442268 commit 62b1e86
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,20 @@ pub async fn list_github_pulls(
}
}


let diff = match octocrab.pulls(&owner, &repo).get_diff(pull.number).await {
Ok(x) if x.len() < 1024*1024*10 => x,
Ok(_) => {
continue
}
Err(e) => {
logkit::error!("Failed to fetch pull request diff for {}: {}",
url, octocrab_error_message(e));
continue
// Fetch the diff only if the number of changed lines is fewer than 100,000,
// assuming 80 characters per line,
// and the size of the diff is less than 8MB.
let diff = if pull.additions.unwrap_or_default() + pull.deletions.unwrap_or_default() < 100*1024 {
match octocrab.pulls(&owner, &repo).get_diff(pull.number).await {
Ok(x) => x,
Err(e) => {
logkit::error!("Failed to fetch pull request diff for {}: {}",
url, octocrab_error_message(e));
continue
}
}
} else {
String::new()
};

let doc = StructuredDoc {
Expand Down

0 comments on commit 62b1e86

Please sign in to comment.