Skip to content

Commit

Permalink
feat: make email optional in coauthor
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed May 13, 2024
1 parent 31f6f83 commit 0b0efb8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
8 changes: 2 additions & 6 deletions buildit-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ pub struct FindUpdate {
pub async fn find_update_and_update_checksum(
pkg: &str,
abbs_path: &Path,
user_name: &str,
user_email: &str,
coauthor: &str,
) -> anyhow::Result<FindUpdate> {
let _lock = ABBS_REPO_LOCK.lock().await;

Expand Down Expand Up @@ -139,10 +138,7 @@ pub async fn find_update_and_update_checksum(
Command::new("git")
.arg("commit")
.arg("-m")
.arg(format!(
"{}\n\nCo-authored-by: {} <{}>",
title, user_name, user_email
))
.arg(format!("{}\n\nCo-authored-by: {}", title, coauthor))
.current_dir(&abbs_path)
.output()
.context("Creating git commit")?;
Expand Down
27 changes: 13 additions & 14 deletions server/src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,20 +726,19 @@ pub async fn answer(bot: Bot, msg: Message, cmd: Command, pool: DbPool) -> Respo
}
};

match find_update_and_update_checksum(
&package,
&ARGS.abbs_path,
user.github_login
.as_ref()
.map(|s| s.as_str())
.unwrap_or("Unknown"),
user.github_email
.as_ref()
.map(|s| s.as_str())
.unwrap_or("[email protected]"),
)
.await
{
let mut coauthor_parts = vec![];
if let Some(name) = &user.github_name {
coauthor_parts.push(name.clone());
}
if let Some(login) = &user.github_login {
coauthor_parts.push(format!("(@{})", login));
}
if let Some(email) = &user.github_email {
coauthor_parts.push(format!("<{}>", email));
}
let coauthor = coauthor_parts.join(" ");

match find_update_and_update_checksum(&package, &ARGS.abbs_path, &coauthor).await {
Ok(f) => {
match buildit_utils::github::open_pr(
app_private_key,
Expand Down

0 comments on commit 0b0efb8

Please sign in to comment.