Skip to content

Handle base branch changed in [autolabel] and check-commits #2093

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

Merged
merged 1 commit into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ pub struct ChangeInner {
pub struct Changes {
pub title: Option<ChangeInner>,
pub body: Option<ChangeInner>,
pub base: Option<ChangeInner>,
}

#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
Expand Down Expand Up @@ -1228,6 +1229,13 @@ pub struct IssuesEvent {
pub sender: User,
}

impl IssuesEvent {
pub fn has_base_changed(&self) -> bool {
matches!(self.action, IssuesAction::Edited)
&& matches!(&self.changes, Some(changes) if changes.base.is_some())
}
}

#[derive(Debug, serde::Deserialize)]
struct PullRequestEventFields {}

Expand Down
2 changes: 2 additions & 0 deletions src/handlers/autolabel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub(super) async fn parse_input(
Some(config) => config,
None => return Ok(None),
};

// On opening a new PR or sync'ing the branch, look at the diff and try to
// add any appropriate labels.
//
Expand All @@ -39,6 +40,7 @@ pub(super) async fn parse_input(
| IssuesAction::ReadyForReview
| IssuesAction::ConvertedToDraft
)
|| event.has_base_changed()
{
let files = if can_trigger_files {
event
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/check_commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ pub(super) async fn handle(ctx: &Context, event: &Event, config: &Config) -> any
| IssuesAction::Reopened
| IssuesAction::Synchronize
| IssuesAction::ReadyForReview
) || !event.issue.is_pr()
) || !event.has_base_changed()
|| !event.issue.is_pr()
{
return Ok(());
}
Expand Down