Skip to content

Commit

Permalink
Merge #305
Browse files Browse the repository at this point in the history
305: TagBot: Handle repos where issues are disabled r=christopher-dG a=christopher-dG

Closes #304

Co-authored-by: Chris de Graaf <me@cdg.dev>
  • Loading branch information
bors[bot] and christopher-dG committed Dec 8, 2020
2 parents 844013d + 6690f3c commit 043f2bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RegistryCI"
uuid = "0c95cc5f-2f7e-43fe-82dd-79dbcba86b32"
authors = ["Dilum Aluthge <dilum@aluthge.com>", "Fredrik Ekre <ekrefredrik@gmail.com>"]
version = "4.5.0"
version = "4.5.1"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand All @@ -23,7 +23,7 @@ VisualStringDistances = "089bb0c6-1854-47b9-96f7-327dbbe09dca"

[compat]
GitHub = "5.2"
HTTP = "0.8, 0.9"
HTTP = "0.8, 0.9.1"
JSON = "0.19, 0.20, 0.21"
RegistryTools = "1.2"
StringDistances = "0.9, 0.10"
Expand Down
18 changes: 14 additions & 4 deletions src/TagBot/TagBot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ function get_repo_notification_issue(repo)
filter!(x -> x.pull_request === nothing, issues)
return if isempty(issues)
@info "Creating new notification issue"
issue = GH.create_issue(repo; auth=AUTH[], params=(;
title=ISSUE_TITLE,
body=ISSUE_BODY,
))
issue = try
GH.create_issue(repo; auth=AUTH[], params=(;
title=ISSUE_TITLE,
body=ISSUE_BODY,
))
catch e
occursin("Issues are disabled", e.msg) || rethrow()
@info "Issues are disabled on $repo"
return nothing
end
GH.edit_issue(repo, issue; auth=AUTH[], params=(; state="closed"))
issue
else
Expand Down Expand Up @@ -131,6 +137,10 @@ function maybe_notify(event, repo, version; cron=false)
return
end
issue = get_repo_notification_issue(repo)
if issue === nothing
@info "Couldn't get notification issue for $repo"
return
end
if cron && should_fixup(repo, issue)
@info "Opening fixup PR for $repo"
open_fixup_pr(repo)
Expand Down
4 changes: 2 additions & 2 deletions test/tagbot-unit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ end

@testset "get_repo_notification_issue" begin
playback("get_repo_notification_issue.bson") do
@test_logs (:info, "Creating new notification issue") begin
@test_logs match_mode=:any (:info, "Creating new notification issue") begin
issue = TB.get_repo_notification_issue("christopher-dG/TestRepo")
@test issue.number == 11
end
@test_logs (:info, "Found existing notification issue") begin
@test_logs match_mode=:any (:info, "Found existing notification issue") begin
issue = TB.get_repo_notification_issue("christopher-dG/TestRepo")
@test issue.number == 11
end
Expand Down

0 comments on commit 043f2bf

Please sign in to comment.