From 3e523901ab72f4c56284d602c0fa05fcb4a790a9 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Thu, 26 Oct 2023 09:55:11 +0200 Subject: [PATCH] Don't change the PR title when package is in deps section --- src/utilities/new_versions.jl | 14 +++++++++----- test/patches.jl | 5 +---- test/utilities/new_versions.jl | 10 ++++++++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/utilities/new_versions.jl b/src/utilities/new_versions.jl index 5d4e3658..9f2ac4be 100644 --- a/src/utilities/new_versions.jl +++ b/src/utilities/new_versions.jl @@ -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, @@ -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) """ @@ -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, @@ -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) """ @@ -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), diff --git a/test/patches.jl b/test/patches.jl index 0fa8ef0a..451f83fb 100644 --- a/test/patches.jl +++ b/test/patches.jl @@ -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) diff --git a/test/utilities/new_versions.jl b/test/utilities/new_versions.jl index 8d4b8397..e6596487 100644 --- a/test/utilities/new_versions.jl +++ b/test/utilities/new_versions.jl @@ -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) @@ -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