Skip to content

Commit 5202224

Browse files
committed
Refactor PR detection in autolabel
1 parent da8a7e7 commit 5202224

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

src/handlers/autolabel.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,20 @@ pub(super) async fn parse_input(
7979
}
8080
}
8181

82-
if let Some(files) = &files {
83-
// This a PR.
84-
85-
// Add the matching labels for the modified files paths
86-
if cfg
87-
.trigger_files
88-
.iter()
89-
.any(|f| files.iter().any(|file_diff| file_diff.path.starts_with(f)))
90-
{
91-
autolabels.push(Label {
92-
name: label.to_owned(),
93-
});
82+
if event.issue.is_pr() {
83+
if let Some(files) = &files {
84+
// This a PR with modified files.
85+
86+
// Add the matching labels for the modified files paths
87+
if cfg
88+
.trigger_files
89+
.iter()
90+
.any(|f| files.iter().any(|file_diff| file_diff.path.starts_with(f)))
91+
{
92+
autolabels.push(Label {
93+
name: label.to_owned(),
94+
});
95+
}
9496
}
9597

9698
// Treat the following situations as a "new PR":
@@ -106,15 +108,12 @@ pub(super) async fn parse_input(
106108
});
107109
state.data.new_pr_labels_applied = true;
108110
}
109-
}
110-
111-
if event.issue.pull_request.is_none()
112-
&& cfg.new_issue
113-
&& event.action == IssuesAction::Opened
114-
{
115-
autolabels.push(Label {
116-
name: label.to_owned(),
117-
});
111+
} else {
112+
if cfg.new_issue && event.action == IssuesAction::Opened {
113+
autolabels.push(Label {
114+
name: label.to_owned(),
115+
});
116+
}
118117
}
119118
}
120119

0 commit comments

Comments
 (0)