Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow strict_version entries #411

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
authors = ["Dilum Aluthge", "Brown Center for Biomedical Informatics", "contributors"]
version = "3.3.0"
version = "3.4.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
4 changes: 2 additions & 2 deletions src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Main entry point for the package.
- `include_yanked=false`: When set to true, yanked versions will be included when calculating what the latest version of a package is
"""
function main(
env::AbstractDict=ENV, ci_cfg::CIService=auto_detect_ci_service(; env=env); kwargs...
env::AbstractDict=ENV, ci_cfg::CIService=auto_detect_ci_service(; env=env); strict_version::Bool=false, kwargs...
)
options = Options(; kwargs...)

Expand All @@ -58,7 +58,7 @@ function main(

for dep in deps
pr = @mock make_pr_for_new_version(
api, repo, dep, options.entry_type, ci_cfg; options, subdir
api, repo, dep, options.entry_type, ci_cfg; strict_version, options, subdir
)

if !isnothing(pr)
Expand Down
9 changes: 7 additions & 2 deletions src/utilities/new_versions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ function new_compat_entry(::EntryType, old_compat::Nothing, new_compat::Abstract
return "$(strip(new_compat))"
end

function compat_version_number(ver::VersionNumber)
function compat_version_number(ver::VersionNumber, handle_equality_in_entries::Bool=false)
handle_equality_in_entries && return "= $(ver.major).$(ver.minor).$(ver.patch)"
(ver.major > 0) && return "$(ver.major)"
(ver.minor > 0) && return "0.$(ver.minor)"

Expand Down Expand Up @@ -208,13 +209,17 @@ function make_pr_for_new_version(
env=ENV,
options::Options,
subdir::String,
strict_version::Bool=false
)
if !continue_with_pr(dep, options.bump_compat_containing_equality_specifier)
return nothing
end

# Get new compat entry version, pr title, and pr body text
compat_entry_for_latest_version = compat_version_number(dep.latest_version)
handle_equality_in_entries = skip_equality_specifiers(
bump_compat_containing_equality_specifier, dep.version_verbatim
) && strict_version
compat_entry_for_latest_version = compat_version_number(dep.latest_version, handle_equality_in_entries)
brand_new_compat = new_compat_entry(
entry_type, dep.version_verbatim, compat_entry_for_latest_version
)
Expand Down
13 changes: 13 additions & 0 deletions test/utilities/new_versions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ end
@test CompatHelper.compat_version_number(vn) == expected
end

@testset "Strict compat_version_number -- $(vn)" for (vn, expected) in [
(VersionNumber("1.0.0"), "= 1.0.0"),
(VersionNumber("1.1.1"), "= 1.1.1"),
(VersionNumber("1.1.0"), "= 1.1.0"),
(VersionNumber("0.1.0"), "= 0.1.0"),
(VersionNumber("0.1.1"), "= 0.1.1"),
(VersionNumber("0.0.1"), "= 0.0.1"),
(VersionNumber("0.0.0"), "= 0.0.0"),
]
handle_equality_in_entries=true
@test CompatHelper.compat_version_number(vn, handle_equality_in_entries) == expected
end

@testset "subdir_string -- $(subdir)" for (subdir, expected) in [
("foobar", "foobar"), ("foo/bar", "bar"), ("1", "1"), ("", "")
]
Expand Down