Skip to content
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
6 changes: 5 additions & 1 deletion src/handlers/check_commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ pub(super) async fn handle(
}

if let Some(issue_links) = &config.issue_links {
warnings.extend(issue_links::issue_links_in_commits(issue_links, &commits));
warnings.extend(issue_links::issue_links_in_commits(
issue_links,
&event.repository.full_name,
&commits,
));
warnings.extend(branch_links::branch_links_in_commits(ctx, issue_links, &commits).await);
}

Expand Down
32 changes: 23 additions & 9 deletions src/handlers/check_commits/issue_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static LINKED_RE: LazyLock<Regex> =

pub(super) fn issue_links_in_commits(
conf: &IssueLinksConfig,
repo: &str,
commits: &[GithubCommit],
) -> Option<String> {
let does_match = match conf.check_commits {
Expand Down Expand Up @@ -40,7 +41,7 @@ pub(super) fn issue_links_in_commits(
) {
Some(format!(
r"There are uncanonicalized issue links (such as `#123`) in the commit messages of the following commits.
*Please add the organization and repository before the issue number (like so `rust-lang/rust#123`) to avoid issues with subtrees.*
*Please add the organization and repository before the issue number (like so `{repo}#123`) to avoid issues with subtrees.*
{issue_links_commits}",
))
} else {
Expand Down Expand Up @@ -76,7 +77,10 @@ fn test_mentions_in_commits() {
"This is simple without issue links!",
)];

assert_eq!(issue_links_in_commits(&config, &commits), None);
assert_eq!(
issue_links_in_commits(&config, "rust-lang/rust", &commits),
None
);

commits.push(dummy_commit_from_body(
"86176475acda9c775f844f5ad2470f05aebd4249",
Expand All @@ -91,15 +95,18 @@ fn test_mentions_in_commits() {
"Merge pull request #2236 from rust-lang/rustc-pull",
));

assert_eq!(issue_links_in_commits(&config, &commits), None);
assert_eq!(
issue_links_in_commits(&config, "rust-lang/rust", &commits),
None
);

commits.push(dummy_commit_from_body(
"d7daa17bc97df9377640b0d33cbd0bbeed703c3a",
"This is a body with a issue link #123.",
));

assert_eq!(
issue_links_in_commits(&config, &commits),
issue_links_in_commits(&config, "rust-lang/rust", &commits),
Some(
r"There are issue links (such as `#123`) in the commit messages of the following commits.
*Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtrees.*
Expand All @@ -113,6 +120,7 @@ fn test_mentions_in_commits() {
&IssueLinksConfig {
check_commits: IssueLinksCheckCommitsConfig::Off,
},
"rust-lang/rust",
&commits
),
None
Expand All @@ -124,7 +132,7 @@ fn test_mentions_in_commits() {
));

assert_eq!(
issue_links_in_commits(&config, &commits),
issue_links_in_commits(&config, "rust-lang/rust", &commits),
Some(
r"There are issue links (such as `#123`) in the commit messages of the following commits.
*Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtrees.*
Expand All @@ -148,25 +156,31 @@ fn uncanonicalized() {
"This is simple without issue links!",
)];

assert_eq!(issue_links_in_commits(&config, &commits), None);
assert_eq!(
issue_links_in_commits(&config, "rust-lang/rust", &commits),
None
);

commits.push(dummy_commit_from_body(
"86176475acda9c775f844f5ad2470f05aebd4249",
"Test for canonicalized rust-lang/rust#123",
));

assert_eq!(issue_links_in_commits(&config, &commits), None);
assert_eq!(
issue_links_in_commits(&config, "rust-lang/rust", &commits),
None
);

commits.push(dummy_commit_from_body(
"fererfe5acda9c775f844f5ad2470f05aebd4249",
"Test for uncanonicalized #123",
));

assert_eq!(
issue_links_in_commits(&config, &commits),
issue_links_in_commits(&config, "rust-lang/rustfmt", &commits),
Some(
r"There are uncanonicalized issue links (such as `#123`) in the commit messages of the following commits.
*Please add the organization and repository before the issue number (like so `rust-lang/rust#123`) to avoid issues with subtrees.*
*Please add the organization and repository before the issue number (like so `rust-lang/rustfmt#123`) to avoid issues with subtrees.*
- fererfe5acda9c775f844f5ad2470f05aebd4249
".to_string()
)
Expand Down
Loading