Skip to content

Commit

Permalink
fix guideline (should return message also)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson committed Jan 30, 2024
1 parent f888e29 commit 30dceed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/AutoMerge/guidelines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,17 @@ const guideline_name_identifier = Guideline(;
docs=string(
"The package name should be a valid Julia identifier (according to `Base.isidentifier`).",
),
check=data -> Base.isidentifier(data.pkg),
check=data -> meets_name_is_identifier(data.pkg),
)

function meets_name_is_identifier(pkg)
if Base.isidentifier(pkg)
return true, ""
else
return false, "The package's name ($pkg) is not a valid Julia identifier according to `Base.isidentifier`. Typically this means it contains `-` or other characters that can't be used in defining a variable name or module. The package must be renamed to be registered."
end
end

const guideline_normal_capitalization = Guideline(;
info="Normal capitalization",
docs=string(
Expand Down
4 changes: 4 additions & 0 deletions test/automerge-unit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ end
end

@testset "Guidelines for new packages" begin
@testset "Package name is a valid identifier" begin
@test AutoMerge.meets_name_is_identifier("Hello")[1]
@test !AutoMerge.meets_name_is_identifier("Hello-GoodBye")[1]
end
@testset "Normal capitalization" begin
@test AutoMerge.meets_normal_capitalization("Zygote")[1] # Regular name
@test AutoMerge.meets_normal_capitalization("Zygote")[1]
Expand Down

0 comments on commit 30dceed

Please sign in to comment.