Skip to content

Commit

Permalink
Add a method for `registration_branch(pkg::String; url::AbstractStrin…
Browse files Browse the repository at this point in the history
…g)` (#89)

* Add a method for `registration_branch(pkg::Project; url::AbstractString)`

* Loosen a constructor's type signature from `String` to `AbstractString`

* Bump the patch version number

* Add test coverage for `register()` where `pkg::String`

* Fix a typo in a test

* Gitignore the `/Manifest.toml` file

* If a test has error metadata, print that metadata to the log

* Fix a test
  • Loading branch information
DilumAluthge authored Apr 3, 2023
1 parent 0b08dcc commit f7e24a4
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ docs/Manifest.toml
test/jl_*
test/jl_*/
test/registries/

Manifest.toml
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RegistryTools"
uuid = "d1eb7eb1-105f-429d-abf5-b0f65cb9e2c4"
authors = ["Stefan Karpinski <[email protected]>"]
version = "2.2.0"
version = "2.2.1"

[deps]
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
Expand Down
2 changes: 1 addition & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct Project
extras::Dict{String, String}
end

Project(project_file::String) = Project(isfile(project_file) ? TOML.parsefile(project_file) : Dict())
Project(project_file::AbstractString) = Project(isfile(project_file) ? TOML.parsefile(project_file) : Dict())
function Project(d::Dict)
name = get(d, "name", nothing)
uuid = get(d, "uuid", nothing)
Expand Down
5 changes: 5 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function gitcmd(path::AbstractString, gitconfig::Dict)
end

"""
registration_branch(pkg::AbstractString; url::AbstractString) -> String
registration_branch(pkg::RegistryTools.Project; url::AbstractString) -> String
Generate the name for the registry branch used to register the package version.
Expand All @@ -21,3 +22,7 @@ function registration_branch(pkg::Project; url::AbstractString)
url_hash_trunc = url_hash[1:10]
return "registrator-$(lowercase(pkg.name))-$(string(pkg.uuid)[1:8])-v$(pkg.version)-$(url_hash_trunc)"
end
function registration_branch(project_file::AbstractString; url::AbstractString)
proj = Project(project_file)
return registration_branch(proj; url = url)
end
71 changes: 38 additions & 33 deletions test/regedit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -622,41 +622,46 @@ end
# version of one of the packages with a dependency to the other
# package. The registration is pushed to a new branch via a file URL.
@testset "register" begin
mktempdir(@__DIR__) do temp_dir
registry1_path = joinpath(temp_dir, "Registry1")
status = create_and_populate_registry(registry1_path, "Registry1",
"7e1d4fce-5fe6-405e-8bac-078d4138e9a2",
"Example1")
@test !haserror(status)

registry2_path = joinpath(@__DIR__, temp_dir, "Registry2")
status = create_and_populate_registry(registry2_path, "Registry2",
"a5a8be26-c942-4674-beee-533a0e81ac1d",
"Dep1")
@test !haserror(status)
for pkg_f in [identity, Project]
mktempdir(@__DIR__) do temp_dir
registry1_path = joinpath(temp_dir, "Registry1")
status = create_and_populate_registry(registry1_path, "Registry1",
"7e1d4fce-5fe6-405e-8bac-078d4138e9a2",
"Example1")
@test !haserror(status)

registry2_path = joinpath(@__DIR__, temp_dir, "Registry2")
status = create_and_populate_registry(registry2_path, "Registry2",
"a5a8be26-c942-4674-beee-533a0e81ac1d",
"Dep1")
@test !haserror(status)

projects_path = joinpath(@__DIR__, "project_files")
project_file = joinpath(projects_path, "Example18.toml")
pkg = pkg_f(project_file)
package_repo = "http://example.com/Example.git"
tree_hash = repeat("0", 40)
registry_repo = "file://$(registry1_path)"
deps_repo = "file://$(registry2_path)"
regbr = register(package_repo, pkg, tree_hash, registry = registry_repo,
registry_deps = [deps_repo], push = true,
gitconfig = TEST_GITCONFIG)
if haskey(regbr.metadata, "error") || haskey(regbr.metadata, "warning")
@info "" get(regbr.metadata, "error", nothing) get(regbr.metadata, "warning", nothing)
end
@test !haskey(regbr.metadata, "error") && !haskey(regbr.metadata, "warning")
git = gitcmd(registry1_path, TEST_GITCONFIG)
branches = readlines(`$git branch`)
@test length(branches) == 2
end

projects_path = joinpath(@__DIR__, "project_files")
project_file = joinpath(projects_path, "Example18.toml")
pkg = Project(project_file)
package_repo = "http://example.com/$(pkg.name).git"
tree_hash = repeat("0", 40)
registry_repo = "file://$(registry1_path)"
deps_repo = "file://$(registry2_path)"
regbr = register(package_repo, pkg, tree_hash, registry = registry_repo,
registry_deps = [deps_repo], push = true,
gitconfig = TEST_GITCONFIG)
@test !haskey(regbr.metadata, "error") && !haskey(regbr.metadata, "warning")
git = gitcmd(registry1_path, TEST_GITCONFIG)
branches = readlines(`$git branch`)
@test length(branches) == 2
# Clean up the registry cache created by `register`.
rm(joinpath(@__DIR__, "registries", "7e1d4fce-5fe6-405e-8bac-078d4138e9a2"),
recursive = true)
rm(joinpath(@__DIR__, "registries", "a5a8be26-c942-4674-beee-533a0e81ac1d"),
recursive = true)
rm(joinpath(@__DIR__, "registries"))
end

# Clean up the registry cache created by `register`.
rm(joinpath(@__DIR__, "registries", "7e1d4fce-5fe6-405e-8bac-078d4138e9a2"),
recursive = true)
rm(joinpath(@__DIR__, "registries", "a5a8be26-c942-4674-beee-533a0e81ac1d"),
recursive = true)
rm(joinpath(@__DIR__, "registries"))
end

@testset "find_registered_version" begin
Expand Down

2 comments on commit f7e24a4

@DilumAluthge
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/80925

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.2.1 -m "<description of version>" f7e24a416bbc2577e539e2e41fe56da0a7685e0c
git push origin v2.2.1

Please sign in to comment.