From ff3aa43d3556892814bc24110ad6131c51e4055d Mon Sep 17 00:00:00 2001 From: adamnfish Date: Mon, 28 Oct 2024 13:33:10 +0000 Subject: [PATCH 1/2] Adds additions / deletions to each PR message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The [API docs](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28) tell us this data is available, it might help teams to prioritise their work approving PRs. This is just a proposal for now, needs to be tested etc. Examples: ``` security-hq#1167 - chore(deps): AWS dependency updates - (opened 3 days ago) 🤖 gu-scala-steward-public-repos[bot] [+1/-1] ``` ``` service-catalogue#1307 - send a configurable number of repos to the dependency graph integrator - (opened 4 days ago) 👤 NovemberTang [+48/-38] ``` --- src/github.rs | 2 ++ src/main.rs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/github.rs b/src/github.rs index 019dbbb..49d9d7e 100644 --- a/src/github.rs +++ b/src/github.rs @@ -14,6 +14,8 @@ pub struct GithubPullRequest { pub head: GithubBranch, pub labels: Vec, pub created_at: DateTime, + pub additions: u32, + pub deletions: u32, } #[derive(Deserialize, Debug)] diff --git a/src/main.rs b/src/main.rs index e136030..aa8384d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -225,7 +225,9 @@ fn make_message(pull_request: GithubPullRequest, show_pr_age: bool) -> String { format!("👤 {}", pull_request.user.login) }; - format!("{}{} \n\n{}\n", message, age_output, user) + let changes = format!("[+{}/-{}]", pull_request.additions, pull_request.deletions); + + format!("{}{} \n\n{} {}\n", message, age_output, user, changes) } fn get_age(d1: DateTime, d2: DateTime) -> String { From 523a605c93fe2ab316acab77e4efa9e55b6bf38f Mon Sep 17 00:00:00 2001 From: adamnfish Date: Mon, 28 Oct 2024 14:53:59 +0000 Subject: [PATCH 2/2] Better name for the additions/deletions PR message fragment --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index aa8384d..fefecdc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -225,9 +225,9 @@ fn make_message(pull_request: GithubPullRequest, show_pr_age: bool) -> String { format!("👤 {}", pull_request.user.login) }; - let changes = format!("[+{}/-{}]", pull_request.additions, pull_request.deletions); + let diff_size = format!("[+{}/-{}]", pull_request.additions, pull_request.deletions); - format!("{}{} \n\n{} {}\n", message, age_output, user, changes) + format!("{}{} \n\n{} {}\n", message, age_output, user, diff_size) } fn get_age(d1: DateTime, d2: DateTime) -> String {