Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(buildit-utils): try to pick first commit message as PR title #26

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions buildit-utils/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use tracing::{debug, error, info, info_span, warn, Instrument};
use walkdir::WalkDir;

use crate::{
ABBS_REPO_LOCK, ALL_ARCH, AMD64, ARM64, COMMITS_COUNT_LIMIT, LOONGARCH64, LOONGSON3, NOARCH, PPC64EL, RISCV64
ABBS_REPO_LOCK, ALL_ARCH, AMD64, ARM64, COMMITS_COUNT_LIMIT, LOONGARCH64, LOONGSON3, NOARCH,
PPC64EL, RISCV64,
};

macro_rules! PR {
Expand Down Expand Up @@ -81,7 +82,7 @@ pub async fn open_pr(
git_ref,
abbs_path,
packages,
title,
mut title,
tags,
archs,
} = openpr_request;
Expand All @@ -94,6 +95,16 @@ pub async fn open_pr(
let commits = task::spawn_blocking(move || get_commits(&abbs_path_clone))
.instrument(info_span!("get_commits"))
.await??;

if title.is_empty() && commits.len() == 1 {
// try to generate title
title = commits[0].msg.0.to_owned();
}

if title.is_empty() {
return Err(OpenPRError::Anyhow(anyhow!("PR title cannot be empty")));
}

let commits = task::spawn_blocking(move || handle_commits(&commits))
.instrument(info_span!("handle_commits"))
.await??;
Expand Down
Loading