Skip to content
Merged
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
6 changes: 2 additions & 4 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,9 @@ version = "1.3.0"

[[deps.RegistryTools]]
deps = ["AutoHashEquals", "LibGit2", "Pkg", "SHA", "UUIDs"]
git-tree-sha1 = "ef658f3c70d6d3b75f75c8f5116d3bc08f5b9243"
repo-rev = "v1.9.0"
repo-url = "https://github.com/JuliaRegistries/RegistryTools.jl.git"
git-tree-sha1 = "8737d3632216c6aaaf8adbfeced16bbcc1208bfd"
uuid = "d1eb7eb1-105f-429d-abf5-b0f65cb9e2c4"
version = "1.9.0"
version = "2.0.0"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Registrator"
uuid = "4418983a-e44d-11e8-3aec-9789530b3b3e"
authors = ["Stefan Karpinski <[email protected]>"]
version = "1.6"
version = "1.7.0"

[deps]
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
Expand Down Expand Up @@ -38,11 +38,11 @@ MbedTLS = "0.6.8, 0.7, 1"
Mocking = "0.7"
Mustache = "0.5, 1.0"
Mux = "0.7, 1"
RegistryTools = "1.9"
RegistryTools = "2"
TimeToLive = "0.2, 0.3"
URIs = "1"
ZMQ = "1"
julia = "1.1"
URIs = "1"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
5 changes: 3 additions & 2 deletions src/RegService.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ using Distributed
using Pkg
using Logging

import RegistryTools: register
import RegistryTools: register, Project
using ..Messaging
import ..RegisterParams

const CONFIG = Dict{String,Any}()

Expand All @@ -16,7 +17,7 @@ include("management.jl")
service(zsock::ReplySocket)
Start a server that calls `RegistryTools.register` on incoming
registration requests from `zsock`. Registration requests
must be serialized `RegistryTools.RegisterParams` objects. Close
must be serialized `RegisterParams` objects. Close
the socket to halt the server.

Parameters:
Expand Down
32 changes: 32 additions & 0 deletions src/Registrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,42 @@ module Registrator
using Base64
using LibGit2
using UUIDs
import RegistryTools

# Remove all of a base64 string's whitespace before decoding it.
decodeb64(s::AbstractString) = String(base64decode(replace(s, r"\s" => "")))


struct RegisterParams
package_repo::String
pkg::RegistryTools.Project
tree_sha::String
registry::String
registry_fork::String
registry_deps::Vector{<:String}
subdir::String
push::Bool
gitconfig::Dict

function RegisterParams(package_repo::AbstractString,
pkg::RegistryTools.Project,
tree_sha::AbstractString;
registry::AbstractString=DEFAULT_REGISTRY_URL,
registry_fork::AbstractString=registry,
registry_deps::Vector{<:AbstractString}=[],
subdir::AbstractString="",
push::Bool=false,
gitconfig::Dict=Dict(),)
new(package_repo, pkg, tree_sha, registry, registry_fork,
registry_deps, subdir, push, gitconfig,)
end
end

RegistryTools.register(regp::RegisterParams) = RegistryTools.register(regp.package_repo, regp.pkg, regp.tree_sha;
registry=regp.registry, registry_fork=regp.registry_fork,
registry_deps=regp.registry_deps,
subdir=regp.subdir, push=regp.push, gitconfig=regp.gitconfig,)

include("slack.jl")
include("pull_request.jl")
include("Messaging.jl")
Expand Down
3 changes: 2 additions & 1 deletion src/commentbot/CommentBot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ using MbedTLS

import Pkg: TOML
import ..Registrator: post_on_slack_channel, pull_request_contents
import RegistryTools: RegBranch, RegisterParams
import RegistryTools: RegBranch, Project
import Base: string
using ..Messaging
import ..RegisterParams

include("trigger_types.jl")
include("parse_comment.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/commentbot/param_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function istagwrong(
end

struct ProcessedParams
project::Union{Nothing, Pkg.Types.Project}
project::Union{Nothing, Project}
projectfile_found::Bool
projectfile_valid::Bool
sha::Union{Nothing, String}
Expand Down
5 changes: 3 additions & 2 deletions src/commentbot/verify_projectfile.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ..Registrator: decodeb64
import RegistryTools

function is_pfile_parseable(c::AbstractString)
@debug("Checking whether (Julia)Project.toml is non-empty and parseable")
Expand All @@ -22,7 +23,7 @@ function is_pfile_parseable(c::AbstractString)
end
end

function pfile_hasfields(p::Pkg.Types.Project)
function pfile_hasfields(p::RegistryTools.Project)
@debug("Checking whether (Julia)Project.toml contains name, uuid and version")
try
if p.name === nothing || p.uuid === nothing || p.version === nothing
Expand Down Expand Up @@ -83,7 +84,7 @@ function verify_projectfile_from_sha(reponame, commit_sha; auth=GitHub.Anonymous

if projectfile_parseable
try
project = Pkg.Types.read_project(copy(IOBuffer(projectfile_contents)))
project = RegistryTools.Project(TOML.parse(projectfile_contents))
catch ex
err = "Failed to read project file"
if isdefined(ex, :msg)
Expand Down
13 changes: 7 additions & 6 deletions src/webui/WebUI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ using Mustache
using URIs

using ..Messaging
import ..RegisterParams

# currently used only in routes/bitbucket.jl
struct Route{Forge, Service} end
Expand Down Expand Up @@ -75,7 +76,7 @@ struct User{U, F <: GitForge.Forge}
end

struct RegistrationData
project::Pkg.Types.Project
project::RegistryTools.Project
tree::String
repo::Union{GitHub.Repo, GitLab.Project, Bitbucket.Repo}
user::Union{GitHub.User, GitLab.User, Bitbucket.User}
Expand Down Expand Up @@ -177,14 +178,14 @@ pathmatch(p::AbstractString, f::Function) = branch(r -> first(split(r.target, "?
firstmatch(p::AbstractString, f::Function) = branch(r -> something(match(SLASH_PAT, r.target), [""])[1] == p[2:end], f)

function action(regdata::RegistrationData, zsock::RequestSocket)
regp = RegistryTools.RegisterParams(
cloneurl(regdata.repo, regdata.is_ssh),
regdata.project,
regp = RegisterParams(
cloneurl(regdata.repo, regdata.is_ssh),
regdata.project,
regdata.tree;
subdir=regdata.subdir,
registry=REGISTRY[].clone,
registry=REGISTRY[].clone,
registry_fork=REGISTRY[].fork_url,
registry_deps=REGISTRY[].deps,
registry_deps=REGISTRY[].deps,
push=true,
)
branch = sendrecv(zsock, regp; nretry=5)
Expand Down
2 changes: 1 addition & 1 deletion src/webui/routes/register.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function register(r::HTTP.Request)
toml = gettoml(u.forge, repo, ref, subdir)
toml === nothing && return json(400; error="(Julia)Project.toml was not found")
project = try
Pkg.Types.read_project(IOBuffer(toml))
RegistryTools.Project(TOML.parse(IOBuffer(toml)))
catch e
@error "Reading project from (Julia)Project.toml failed" exception=get_backtrace(e)
return json(400; error="(Julia)Project.toml is invalid")
Expand Down