Skip to content

Commit

Permalink
Try #411:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Apr 21, 2022
2 parents 1b46ec0 + 47be28c commit 300fb34
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
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.1.0"
version = "3.2.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
2 changes: 2 additions & 0 deletions src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function main(
unsub_from_prs=false,
cc_user=false,
bump_version=false,
strict_version::Bool=false
)
generated_prs = Vector{Union{GitHub.PullRequest,GitLab.MergeRequest}}()

Expand Down Expand Up @@ -93,6 +94,7 @@ function main(
unsub_from_prs=unsub_from_prs,
cc_user=cc_user,
bump_version=bump_version,
strict_version=strict_version
)

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 @@ -213,13 +214,17 @@ function make_pr_for_new_version(
unsub_from_prs=false,
cc_user=false,
bump_version=false,
strict_version::Bool=false
)
if !continue_with_pr(dep, 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

0 comments on commit 300fb34

Please sign in to comment.