Skip to content

Commit 44ec1e5

Browse files
committed
Handle base branch changed in [autolabel] and check-commits
1 parent 30676bf commit 44ec1e5

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/github.rs

Lines changed: 1 addition & 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)]

src/handlers/autolabel.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,26 @@ 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
//
2627
// FIXME: This will re-apply labels after a push that the user had tried to
2728
// remove. Not much can be done about that currently; the before/after on
2829
// synchronize may be straddling a rebase, which will break diff generation.
29-
if matches!(
30+
let has_state_changed = matches!(
3031
event.action,
3132
IssuesAction::Opened
3233
| IssuesAction::Closed
3334
| IssuesAction::Reopened
3435
| IssuesAction::Synchronize
3536
| IssuesAction::ReadyForReview
3637
| IssuesAction::ConvertedToDraft
37-
) {
38+
);
39+
let has_base_changed = matches!(event.action, IssuesAction::Edited)
40+
&& matches!(&event.changes, Some(changes) if changes.base.is_some());
41+
42+
if has_state_changed || has_base_changed {
3843
let files = event
3944
.issue
4045
.diff(&ctx.github)

src/handlers/check_commits.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ pub(super) async fn handle(ctx: &Context, event: &Event, config: &Config) -> any
4444
return Ok(());
4545
};
4646

47+
let has_base_changed = matches!(event.action, IssuesAction::Edited)
48+
&& matches!(&event.changes, Some(changes) if changes.base.is_some());
49+
4750
if !matches!(
4851
event.action,
4952
IssuesAction::Opened
5053
| IssuesAction::Reopened
5154
| IssuesAction::Synchronize
5255
| IssuesAction::ReadyForReview
53-
) || !event.issue.is_pr()
56+
) || !has_base_changed
57+
|| !event.issue.is_pr()
5458
{
5559
return Ok(());
5660
}

0 commit comments

Comments
 (0)