JuliaCI/PkgTemplates.jl

check if name is similar to existing package?

Open

#292 opened on May 9, 2021

View on GitHub
 (6 comments) (5 reactions) (0 assignees)Julia (697 stars) (112 forks)batch import
help wantednew-feature

Description

One can use

using RegistryCI
using RegistryCI.AutoMerge
function is_far_from_existing_names(name)
    path_to_registry = joinpath(DEPOT_PATH[1], "registries", "General")
    all_pkg_names = AutoMerge.get_all_non_jll_package_names(path_to_registry)
    return AutoMerge.meets_distance_check(name, all_pkg_names)
end

to check if a proposed package name will pass AutoMerge's check about package names (as documented in the General registry's README, https://github.com/JuliaRegistries/General#automatic-merging-of-pull-requests).

I thought it could be helpful if PkgTemplates (perhaps optionally) runs this check at package-creation time. It could also support multiple registries (although obviously AutoMerge for General only looks at General, it can still be good to know if there are similar names in another registry you are using), e.g.

using RegistryCI
using RegistryCI.AutoMerge
function is_far_from_existing_names(name)
    names = String[]
    for registry in readdir(joinpath(DEPOT_PATH[1], "registries"); join=true)
        append!(names, AutoMerge.get_all_non_jll_package_names(registry))
    end
    return AutoMerge.meets_distance_check(name, names)
end

(Perhaps we should add a real API for this in RegistryCI though, if it's going to be used programatically)

Contributor guide