Skip to content
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
40 changes: 33 additions & 7 deletions src/register.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,21 @@ end
function update_versions_file(pkg::Project,
versions_file::AbstractString,
versions_data::Dict{String, Any},
tree_hash::AbstractString)
tree_hash::AbstractString;
commit_hash::Union{AbstractString,Nothing}=nothing,
tag_name::Union{AbstractString,Nothing}=nothing,
subdir::AbstractString="",
)
version_info = Dict{String, Any}("git-tree-sha1" => string(tree_hash))
if !isnothing(commit_hash)
version_info["git-commit-sha1"] = commit_hash
end
if !isnothing(tag_name)
version_info["git-tag-name"] = tag_name
end
if subdir != ""
version_info["subdir"] = subdir
end
versions_data[string(pkg.version)] = version_info

open(versions_file, "w") do io
Expand All @@ -341,10 +354,16 @@ function update_versions_file(pkg::Project,
else
if x == "git-tree-sha1"
return 1
elseif x == "yanked"
elseif x == "git-commit-sha1"
return 2
else
elseif x == "git-tag-name"
return 3
elseif x == "subdir"
return 4
elseif x == "yanked"
return 100
else
return 200
end
end
end
Expand Down Expand Up @@ -528,7 +547,8 @@ end

function check_and_update_registry_files(pkg::Project, package_repo, tree_hash,
registry_path, registry_deps_paths,
status; subdir = "")
status;
commit_hash = nothing, tag_name = nothing, subdir = "")
# find package in registry
@debug("find package in registry")
registry_file = joinpath(registry_path, "Registry.toml")
Expand All @@ -548,7 +568,8 @@ function check_and_update_registry_files(pkg::Project, package_repo, tree_hash,
versions_file, versions_data = get_versions_file(package_path)
old_versions = check_versions!(pkg, versions_data, status)
haserror(status) && return
update_versions_file(pkg, versions_file, versions_data, tree_hash)
update_versions_file(pkg, versions_file, versions_data, tree_hash;
commit_hash = commit_hash, tag_name = tag_name, subdir = subdir)

# update package data: deps file
@debug("update package data: deps file")
Expand Down Expand Up @@ -586,7 +607,9 @@ errors or warnings that occurred.
* `registry_fork::AbstractString=registry: the git repository URL for a fork of the registry
* `registry_deps::Vector{String}=[]`: the git repository URLs for any registries containing
packages depended on by `pkg`
* `subdir::AbstractString=""`: path to package within `package_repo`
* `commit_hash::Union{AbstractString, Nothing}`: commit hash of the package revision (optional)
* `tag_name::Union{AbstractString, Nothing}`: tag name of the package revision (optional)
* `subdir::AbstractString=""`: path to package tree within `package_repo`
* `push::Bool=false`: whether to push a registration branch to `registry` for consideration
* `gitconfig::Dict=Dict()`: dictionary of configuration options for the `git` command
"""
Expand All @@ -595,6 +618,8 @@ function register(
registry::AbstractString = DEFAULT_REGISTRY_URL,
registry_fork::AbstractString = registry,
registry_deps::Vector{<:AbstractString} = AbstractString[],
commit_hash::Union{AbstractString,Nothing} = nothing,
tag_name::Union{AbstractString,Nothing} = nothing,
subdir::AbstractString = "",
checks_triggering_error = registrator_errors,
push::Bool = false,
Expand Down Expand Up @@ -643,7 +668,8 @@ function register(

check_and_update_registry_files(pkg, package_repo, tree_hash,
registry_path, registry_deps_paths,
status, subdir = subdir)
status;
commit_hash=commit_hash, tag_name=tag_name, subdir=subdir)
haserror(status) && return set_metadata!(regbr, status)

regtreesha = get_registrator_tree_sha()
Expand Down
13 changes: 13 additions & 0 deletions test/regedit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,19 @@ end
@test collect(keys(data["1.0.0"])) == ["git-tree-sha1"]
@test data["1.0.0"]["git-tree-sha1"] == tree_hash

commit_hash = repeat("1", 40)
subdir = "sub/dir"
update_versions_file(pkg, filename, data, tree_hash; commit_hash=commit_hash, subdir=subdir)

_, data = get_versions_file(temp_dir)
@test data isa Dict
@test collect(keys(data)) == ["1.0.0"]
@test data["1.0.0"] isa Dict
@test sort!(collect(keys(data["1.0.0"]))) == ["git-commit-sha1", "git-tree-sha1", "subdir"]
@test data["1.0.0"]["git-tree-sha1"] == tree_hash
@test data["1.0.0"]["git-commit-sha1"] == commit_hash
@test data["1.0.0"]["subdir"] == subdir

check_versions!(pkg, data, status)
# This version was just registered, should be a complaint now.
@test haserror(status)
Expand Down