Skip to content

Commit

Permalink
Don't change the PR title when package is in deps section
Browse files Browse the repository at this point in the history
  • Loading branch information
sethaxen committed Oct 26, 2023
1 parent 3978cb2 commit 3e52390
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
14 changes: 9 additions & 5 deletions src/utilities/new_versions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ function subdir_string(subdir::AbstractString)
end
end

function section_string(section::AbstractString)
return section == "deps" ? "" : " in [$(section)]"
end

function pr_info(
compat_entry_verbatim::Nothing,
name::AbstractString,
section::AbstractString,
section_str::AbstractString,
compat_entry_for_latest_version::AbstractString,
compat_entry::AbstractString,
subdir_string::AbstractString,
Expand All @@ -55,7 +59,7 @@ function pr_info(
pr_title_prefix::String,
)
new_pr_title = m"""
$(pr_title_prefix)CompatHelper: add new compat entry for $(name) in [$(section)] at version
$(pr_title_prefix)CompatHelper: add new compat entry for $(name)$(section_str) at version
$(compat_entry_for_latest_version)$(subdir_string)$(pr_title_parenthetical)
"""

Expand All @@ -74,7 +78,7 @@ end
function pr_info(
compat_entry_verbatim::AbstractString,
name::AbstractString,
section::AbstractString,
section_str::AbstractString,
compat_entry_for_latest_version::AbstractString,
compat_entry::AbstractString,
subdir_string::AbstractString,
Expand All @@ -83,7 +87,7 @@ function pr_info(
pr_title_prefix::String,
)
new_pr_title = m"""
$(pr_title_prefix)CompatHelper: bump compat for $(name) in [$(section)] to
$(pr_title_prefix)CompatHelper: bump compat for $(name)$(section_str) to
$(compat_entry_for_latest_version)$(subdir_string)$(pr_title_parenthetical)
"""

Expand Down Expand Up @@ -225,7 +229,7 @@ function make_pr_for_new_version(
new_pr_title, new_pr_body = pr_info(
dep.version_verbatim,
dep.package.name,
dep_section,
section_string(dep_section),
compat_entry_for_latest_version,
brand_new_compat,
subdir_string(subdir),
Expand Down
5 changes: 1 addition & 4 deletions test/patches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ end
pr_titles_mock = @patch function CompatHelper.get_pr_titles(
::GitForge.Forge, ::GitHub.Repo, ::String
)
return [
"CompatHelper: bump compat for PackageA in [deps] to 1, (keep existing compat)",
"foo",
]
return ["CompatHelper: bump compat for PackageA to 1, (keep existing compat)", "foo"]
end

function make_clone_https_patch(dir::AbstractString)
Expand Down
10 changes: 8 additions & 2 deletions test/utilities/new_versions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ end
end
end

@testset "section_string -- $(section)" for (section, expected) in
[("deps", ""), ("weakdeps", " in [weakdeps]")]
@test CompatHelper.section_string(section) == expected
end

@testset "skip_equality_specifiers" begin
cases = [
(false, "=", true)
Expand All @@ -112,10 +117,11 @@ end
("", "bump compat for", "pull request changes the compat", "weakdeps")
]
verbatim, expected_title, expected_body, section = case
title, body = CompatHelper.pr_info(verbatim, "", section, "", "", "", "", "", "")
section_str = section == "deps" ? "" : " in [$section]"
title, body = CompatHelper.pr_info(verbatim, "", section_str, "", "", "", "", "", "")

@test contains(title, expected_title)
@test contains(title, " [$section]")
section === "weakdeps" && @test contains(title, section_str)
@test contains(body, expected_body)
end

Expand Down

0 comments on commit 3e52390

Please sign in to comment.