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
2 changes: 1 addition & 1 deletion src/webui/WebUI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function action(regdata::RegistrationData, zsock::RequestSocket)
# Make the PR.
pr = @gf make_registration_request(REGISTRY[], branch.branch, title, body)
if pr === nothing
msg = "Registration failed: Making pull request failed"
msg = "Failed to create or update pull request"
state = :errored
else
url = web_url(pr)
Expand Down
36 changes: 27 additions & 9 deletions src/webui/gitutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,16 @@ function make_registration_request(
catch ex
resp = ex isa GitForge.HTTPError || ex isa GitForge.PostProcessorError ? ex.response : nothing
if !ensure_already_exists(data -> get(data, "message", String[]), resp, 409)
@error "Exception making registration request" repoid=repoid base=base head=branch exception=ex,catch_backtrace()
return result, nothing
@error "An error occurred when creating pull request" repoid=repoid base=base head=branch exception=ex,catch_backtrace()
return nothing, nothing
end
val, _ = get_pull_requests(r.forge, repoid; source_branch=branch, target_branch=base, state="opened")
@assert length(val) == 1

if length(val) != 1
@error "Expected to find one open pull request created from a previous registration attempt but got $(length(val)) pull requests" repoid=repoid base=base head=branch exception=ex,catch_backtrace()
return nothing, nothing
end

prid = first(val).iid
update_pull_request(r.forge, repoid, prid; title=title, body=body)
val[1], nothing
Expand Down Expand Up @@ -329,12 +334,19 @@ function make_registration_request(
exists = ensure_already_exists(resp, 422) do data
map(e -> get(e, "message", ""), get(data, "errors", []))
end

if !exists
@error "Exception making registration request" owner=owner repo=repo base=base head=branch exception=ex,catch_backtrace()
return result, nothing
@error "An error occurred when creating pull request" owner=owner repo=repo base=base head=branch exception=ex,catch_backtrace()
return nothing, nothing
end

val, _ = get_pull_requests(r.forge, owner, repo; head="$owner:$branch", base=base, state="open")
@assert length(val) == 1

if length(val) != 1
@error "Expected to find one open pull request created from a previous registration attempt but got $(length(val)) pull requests" owner=owner repo=repo base=base head=branch exception=ex,catch_backtrace()
return nothing, nothing
end

prid = first(val).number
update_pull_request(r.forge, owner, repo, prid; title=title, body=body)
val[1], nothing
Expand Down Expand Up @@ -363,9 +375,10 @@ function make_registration_request(
exists = ensure_already_exists(resp, 422) do data
map(e -> get(e, "message", ""), get(data, "errors", []))
end

if !exists
@error "Exception making registration request" owner=owner repo=repo base=base head=branch exception=ex, catch_backtrace()
rethrow(ex)
@error "An error occurred when creating pull request" owner=owner repo=repo base=base head=branch exception=ex,catch_backtrace()
return nothing, nothing
end

val, _ = get_pull_requests(r.forge, owner, repo; query=Dict(
Expand All @@ -374,7 +387,12 @@ function make_registration_request(
author.username \"$owner\" AND
destination.branch.name = \"$base\"""", "\n"=> " ")
))
@assert length(val) == 1

if length(val) != 1
@error "Expected to find one open pull request created from a previous registration attempt but got $(length(val)) pull requests" owner=owner repo=repo base=base head=branch exception=ex,catch_backtrace()
return nothing, nothing
end

prid = first(val).id
update_pull_request(r.forge, owner, repo, prid; title=title, body=body)
val[1], nothing
Expand Down