Skip to content

Commit

Permalink
Merge pull request #36 from guardian/aa/add-username
Browse files Browse the repository at this point in the history
feat: Demarcate bot raised PRs
  • Loading branch information
akash1810 authored Oct 23, 2024
2 parents d2e9ab6 + 26de81a commit ffc4f08
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,31 @@ async fn main() -> Result<(), Error> {
}

fn make_message(pull_request: GithubPullRequest, show_pr_age: bool) -> String {
let prefix = if pull_request.user.login.contains("[bot]") {
"🤖🤖🤖 ".to_string()
} else {
"".to_string()
};

let message = format!(
"<{}|{}#{}> - {}",
"{}<{}|{}#{}> - {}",
prefix,
pull_request.html_url.replace("https://", ""),
pull_request.head.repo.name,
pull_request.number,
pull_request.title
);

let age_output = match show_pr_age {
true => format!(" - (_{}_)", get_age(Utc::now(), pull_request.created_at)),
false => "".to_string(),
let age_output = if show_pr_age {
format!(" - (_{}_)", get_age(Utc::now(), pull_request.created_at))
} else {
"".to_string()
};

format!("{}{}\n", message, age_output)
format!(
"{}{} \n\nby {}\n",
message, age_output, pull_request.user.login
)
}

fn get_age(d1: DateTime<Utc>, d2: DateTime<Utc>) -> String {
Expand Down

0 comments on commit ffc4f08

Please sign in to comment.