Skip to content

Commit e068115

Browse files
committed
Handle base branch changed in [autolabel] and check-commits
1 parent 807a8af commit e068115

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/github.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ pub struct ChangeInner {
11161116
pub struct Changes {
11171117
pub title: Option<ChangeInner>,
11181118
pub body: Option<ChangeInner>,
1119+
pub base: Option<ChangeInner>,
11191120
}
11201121

11211122
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
@@ -1228,6 +1229,13 @@ pub struct IssuesEvent {
12281229
pub sender: User,
12291230
}
12301231

1232+
impl IssuesEvent {
1233+
pub fn has_base_changed(&self) -> bool {
1234+
matches!(self.action, IssuesAction::Edited)
1235+
&& matches!(&self.changes, Some(changes) if changes.base.is_some())
1236+
}
1237+
}
1238+
12311239
#[derive(Debug, serde::Deserialize)]
12321240
struct PullRequestEventFields {}
12331241

src/handlers/autolabel.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(super) async fn parse_input(
2020
Some(config) => config,
2121
None => return Ok(None),
2222
};
23+
2324
// On opening a new PR or sync'ing the branch, look at the diff and try to
2425
// add any appropriate labels.
2526
//
@@ -39,6 +40,7 @@ pub(super) async fn parse_input(
3940
| IssuesAction::ReadyForReview
4041
| IssuesAction::ConvertedToDraft
4142
)
43+
|| event.has_base_changed()
4244
{
4345
let files = if can_trigger_files {
4446
event

src/handlers/check_commits.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ pub(super) async fn handle(ctx: &Context, event: &Event, config: &Config) -> any
5050
| IssuesAction::Reopened
5151
| IssuesAction::Synchronize
5252
| IssuesAction::ReadyForReview
53-
) || !event.issue.is_pr()
53+
) || !event.has_base_changed()
54+
|| !event.issue.is_pr()
5455
{
5556
return Ok(());
5657
}

0 commit comments

Comments
 (0)