Skip to content

Commit bf3ff6b

Browse files
authored
🤖 Automatically format the source code files
1 parent c96767c commit bf3ff6b

31 files changed

+1867
-1383
lines changed

bin/remember_to_update_registryci.jl

Lines changed: 85 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,31 @@ using Pkg
77
# Some of the code in this file is taken from:
88
# https://github.com/bcbi/CompatHelper.jl
99

10-
struct AlwaysAssertionError <: Exception
11-
end
10+
struct AlwaysAssertionError <: Exception end
1211

1312
@inline function always_assert(cond::Bool)::Nothing
1413
cond || throw(AlwaysAssertionError())
1514
return nothing
1615
end
1716

18-
function get_all_pull_requests(api::GitHub.GitHubAPI,
19-
repo::GitHub.Repo,
20-
state::String;
21-
auth::GitHub.Authorization,
22-
per_page::Integer = 100,
23-
page_limit::Integer = 100)
17+
function get_all_pull_requests(
18+
api::GitHub.GitHubAPI,
19+
repo::GitHub.Repo,
20+
state::String;
21+
auth::GitHub.Authorization,
22+
per_page::Integer=100,
23+
page_limit::Integer=100,
24+
)
2425
all_pull_requests = Vector{GitHub.PullRequest}(undef, 0)
25-
myparams = Dict("state" => state,
26-
"per_page" => per_page,
27-
"page" => 1)
28-
prs, page_data = GitHub.pull_requests(api, repo;
29-
auth=auth,
30-
params = myparams,
31-
page_limit = page_limit)
26+
myparams = Dict("state" => state, "per_page" => per_page, "page" => 1)
27+
prs, page_data = GitHub.pull_requests(
28+
api, repo; auth=auth, params=myparams, page_limit=page_limit
29+
)
3230
append!(all_pull_requests, prs)
3331
while haskey(page_data, "next")
34-
prs, page_data = GitHub.pull_requests(api, repo;
35-
auth=auth,
36-
page_limit = page_limit,
37-
start_page = page_data["next"])
32+
prs, page_data = GitHub.pull_requests(
33+
api, repo; auth=auth, page_limit=page_limit, start_page=page_data["next"]
34+
)
3835
append!(all_pull_requests, prs)
3936
end
4037
unique!(all_pull_requests)
@@ -45,19 +42,22 @@ _repos_are_the_same(::GitHub.Repo, ::Nothing) = false
4542
_repos_are_the_same(::Nothing, ::GitHub.Repo) = false
4643
_repos_are_the_same(::Nothing, ::Nothing) = false
4744
function _repos_are_the_same(x::GitHub.Repo, y::GitHub.Repo)
48-
if x.name == y.name && x.full_name == y.full_name &&
49-
x.owner == y.owner &&
50-
x.id == y.id &&
51-
x.url == y.url &&
52-
x.html_url == y.html_url &&
53-
x.fork == y.fork
54-
return true
45+
if x.name == y.name &&
46+
x.full_name == y.full_name &&
47+
x.owner == y.owner &&
48+
x.id == y.id &&
49+
x.url == y.url &&
50+
x.html_url == y.html_url &&
51+
x.fork == y.fork
52+
return true
5553
else
5654
return false
5755
end
5856
end
5957

60-
function exclude_pull_requests_from_forks(repo::GitHub.Repo, pr_list::Vector{GitHub.PullRequest})
58+
function exclude_pull_requests_from_forks(
59+
repo::GitHub.Repo, pr_list::Vector{GitHub.PullRequest}
60+
)
6161
non_forked_pull_requests = Vector{GitHub.PullRequest}(undef, 0)
6262
for pr in pr_list
6363
always_assert(_repos_are_the_same(repo, pr.base.repo))
@@ -72,7 +72,7 @@ function only_my_pull_requests(pr_list::Vector{GitHub.PullRequest}; my_username:
7272
_my_username_lowercase = lowercase(strip(my_username))
7373
n = length(pr_list)
7474
pr_is_mine = BitVector(undef, n)
75-
for i = 1:n
75+
for i in 1:n
7676
pr_user_login = pr_list[i].user.login
7777
if lowercase(strip(pr_user_login)) == _my_username_lowercase
7878
pr_is_mine[i] = true
@@ -84,19 +84,21 @@ function only_my_pull_requests(pr_list::Vector{GitHub.PullRequest}; my_username:
8484
return my_pr_list
8585
end
8686

87-
function create_new_pull_request(api::GitHub.GitHubAPI,
88-
repo::GitHub.Repo;
89-
base_branch::String,
90-
head_branch::String,
91-
title::String,
92-
body::String,
93-
auth::GitHub.Authorization)
94-
params = Dict{String, String}()
87+
function create_new_pull_request(
88+
api::GitHub.GitHubAPI,
89+
repo::GitHub.Repo;
90+
base_branch::String,
91+
head_branch::String,
92+
title::String,
93+
body::String,
94+
auth::GitHub.Authorization,
95+
)
96+
params = Dict{String,String}()
9597
params["title"] = title
9698
params["head"] = head_branch
9799
params["base"] = base_branch
98100
params["body"] = body
99-
result = GitHub.create_pull_request(api, repo; params = params, auth = auth)
101+
result = GitHub.create_pull_request(api, repo; params=params, auth=auth)
100102
return result
101103
end
102104

@@ -130,46 +132,50 @@ function set_git_identity(username, email)
130132
return nothing
131133
end
132134

133-
function create_new_pull_request(api::GitHub.GitHubAPI,
134-
repo::GitHub.Repo;
135-
base_branch::String,
136-
head_branch::String,
137-
title::String,
138-
body::String,
139-
auth::GitHub.Authorization)
140-
params = Dict{String, String}()
135+
function create_new_pull_request(
136+
api::GitHub.GitHubAPI,
137+
repo::GitHub.Repo;
138+
base_branch::String,
139+
head_branch::String,
140+
title::String,
141+
body::String,
142+
auth::GitHub.Authorization,
143+
)
144+
params = Dict{String,String}()
141145
params["title"] = title
142146
params["head"] = head_branch
143147
params["base"] = base_branch
144148
params["body"] = body
145-
result = GitHub.create_pull_request(api, repo; params = params, auth = auth)
149+
result = GitHub.create_pull_request(api, repo; params=params, auth=auth)
146150
return result
147151
end
148152

149-
function main(relative_path;
150-
registry,
151-
github_token = ENV["GITHUB_TOKEN"],
152-
master_branch = "master",
153-
pr_branch = "github_actions/remember_to_update_registryci",
154-
pr_title = "Update RegistryCI.jl by updating the .ci/Manifest.toml file",
155-
cc_usernames = String[],
156-
my_username = "github-actions[bot]",
157-
my_email = "41898282+github-actions[bot]@users.noreply.github.com")
153+
function main(
154+
relative_path;
155+
registry,
156+
github_token=ENV["GITHUB_TOKEN"],
157+
master_branch="master",
158+
pr_branch="github_actions/remember_to_update_registryci",
159+
pr_title="Update RegistryCI.jl by updating the .ci/Manifest.toml file",
160+
cc_usernames=String[],
161+
my_username="github-actions[bot]",
162+
my_email="41898282+github-actions[bot]@users.noreply.github.com",
163+
)
158164
original_project = Base.active_project()
159165
original_directory = pwd()
160166
api = GitHubWebAPI(HTTP.URI("https://api.github.com"))
161167
tmp_dir = mktempdir()
162-
atexit(() -> rm(tmp_dir; force = true, recursive = true))
168+
atexit(() -> rm(tmp_dir; force=true, recursive=true))
163169
cd(tmp_dir)
164170

165171
auth = GitHub.authenticate(api, github_token)
166-
my_repo = GitHub.repo(api, registry; auth = auth)
172+
my_repo = GitHub.repo(api, registry; auth=auth)
167173
registry_url_with_auth = "https://x-access-token:$(github_token)@github.com/$(registry)"
168-
_all_open_prs = get_all_pull_requests(api, my_repo, "open"; auth = auth)
174+
_all_open_prs = get_all_pull_requests(api, my_repo, "open"; auth=auth)
169175
_nonforked_prs = exclude_pull_requests_from_forks(my_repo, _all_open_prs)
170-
pr_list = only_my_pull_requests(_nonforked_prs; my_username = my_username)
176+
pr_list = only_my_pull_requests(_nonforked_prs; my_username=my_username)
171177
pr_titles = Vector{String}(undef, length(pr_list))
172-
for i = 1:length(pr_list)
178+
for i in 1:length(pr_list)
173179
pr_titles[i] = convert(String, strip(pr_list[i].title))::String
174180
end
175181

@@ -187,7 +193,7 @@ function main(relative_path;
187193
end
188194
cd(relative_path)
189195
manifest_filename = joinpath(pwd(), "Manifest.toml")
190-
rm(manifest_filename; force = true, recursive = true)
196+
rm(manifest_filename; force=true, recursive=true)
191197
Pkg.activate(pwd())
192198
Pkg.instantiate()
193199
Pkg.update()
@@ -207,22 +213,29 @@ function main(relative_path;
207213
if pr_title in pr_titles
208214
@info("An open PR with the title already exists", pr_title)
209215
else
210-
new_pr_body = strip(string("This pull request updates ",
211-
"RegistryCI.jl by updating the ",
212-
"`.ci/Manifest.toml` file.\n\n",
213-
username_mentions_text))
216+
new_pr_body = strip(
217+
string(
218+
"This pull request updates ",
219+
"RegistryCI.jl by updating the ",
220+
"`.ci/Manifest.toml` file.\n\n",
221+
username_mentions_text,
222+
),
223+
)
214224
_new_pr_body = convert(String, strip(new_pr_body))
215-
create_new_pull_request(api, my_repo;
216-
base_branch = master_branch,
217-
head_branch = pr_branch,
218-
title = pr_title,
219-
body = _new_pr_body,
220-
auth = auth)
225+
create_new_pull_request(
226+
api,
227+
my_repo;
228+
base_branch=master_branch,
229+
head_branch=pr_branch,
230+
title=pr_title,
231+
body=_new_pr_body,
232+
auth=auth,
233+
)
221234
end
222235
end
223236

224237
cd(original_directory)
225-
rm(tmp_dir; force = true, recursive = true)
238+
rm(tmp_dir; force=true, recursive=true)
226239
Pkg.activate(original_project)
227240
return commit_was_success
228241
end

docs/make.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ makedocs(;
2424
strict=true,
2525
)
2626

27-
deploydocs(;
28-
repo="github.com/JuliaRegistries/RegistryCI.jl",
29-
push_preview=false,
30-
)
27+
deploydocs(; repo="github.com/JuliaRegistries/RegistryCI.jl", push_preview=false)

src/AutoMerge/AutoMerge.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
module AutoMerge
22

3-
import Dates
3+
using Dates: Dates
44
# import GitCommand
5-
import GitHub
6-
import HTTP
7-
import LibGit2
8-
import Pkg
9-
import TimeZones
10-
import JSON
11-
import VisualStringDistances
12-
import StringDistances
13-
import LicenseCheck
14-
import TOML
15-
import Printf
16-
import RegistryTools
17-
import ..RegistryCI
18-
import Tar
5+
using GitHub: GitHub
6+
using HTTP: HTTP
7+
using LibGit2: LibGit2
8+
using Pkg: Pkg
9+
using TimeZones: TimeZones
10+
using JSON: JSON
11+
using VisualStringDistances: VisualStringDistances
12+
using StringDistances: StringDistances
13+
using LicenseCheck: LicenseCheck
14+
using TOML: TOML
15+
using Printf: Printf
16+
using RegistryTools: RegistryTools
17+
using ..RegistryCI: RegistryCI
18+
using Tar: Tar
1919

2020
include("types.jl")
2121
include("ciservice.jl")

src/AutoMerge/api_rate_limiting.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
function my_retry(f::Function)
2-
delays = ExponentialBackOff(;
3-
n = 10,
4-
max_delay = 30.0,
5-
)
6-
return retry(f; delays = delays)()
2+
delays = ExponentialBackOff(; n=10, max_delay=30.0)
3+
return retry(f; delays=delays)()
74
end

src/AutoMerge/automerge_comment.jl

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
function update_automerge_comment!(data::GitHubAutoMergeData,
2-
body::AbstractString)::Nothing
1+
function update_automerge_comment!(data::GitHubAutoMergeData, body::AbstractString)::Nothing
32
if data.read_only
43
@info "`read_only` mode; skipping updating automerge comment."
54
return nothing
@@ -10,52 +9,42 @@ function update_automerge_comment!(data::GitHubAutoMergeData,
109
auth = data.auth
1110
whoami = data.whoami
1211

13-
my_comments = my_retry(() -> get_all_my_pull_request_comments(api,
14-
repo,
15-
pr;
16-
auth = auth,
17-
whoami = whoami))
12+
my_comments = my_retry(
13+
() -> get_all_my_pull_request_comments(api, repo, pr; auth=auth, whoami=whoami)
14+
)
1815
num_comments = length(my_comments)
19-
_body = string(strip(string(body,
20-
"\n",
21-
"<!---\n",
22-
"this_is_the_single_automerge_comment\n",
23-
"--->\n")))
16+
_body = string(
17+
strip(
18+
string(
19+
body, "\n", "<!---\n", "this_is_the_single_automerge_comment\n", "--->\n"
20+
),
21+
),
22+
)
2423
if num_comments > 1
25-
for i = 2:num_comments
24+
for i in 2:num_comments
2625
comment_to_delete = my_comments[i]
2726
try
28-
my_retry(() -> delete_comment!(api, repo,
29-
pr,
30-
comment_to_delete;
31-
auth = auth))
27+
my_retry(() -> delete_comment!(api, repo, pr, comment_to_delete; auth=auth))
3228
catch ex
33-
@error("Ignoring error: ", exception=(ex, catch_backtrace()))
29+
@error("Ignoring error: ", exception = (ex, catch_backtrace()))
3430
end
3531
end
3632
comment_to_update = my_comments[1]
3733
if strip(comment_to_update.body) != _body
38-
my_retry(() -> edit_comment!(api, repo,
39-
pr,
40-
comment_to_update,
41-
_body;
42-
auth = auth))
34+
my_retry(
35+
() -> edit_comment!(api, repo, pr, comment_to_update, _body; auth=auth)
36+
)
4337
end
4438
elseif num_comments == 1
4539
comment_to_update = my_comments[1]
4640
if strip(comment_to_update.body) != _body
47-
my_retry(() -> edit_comment!(api, repo,
48-
pr,
49-
comment_to_update,
50-
_body;
51-
auth = auth))
41+
my_retry(
42+
() -> edit_comment!(api, repo, pr, comment_to_update, _body; auth=auth)
43+
)
5244
end
5345
else
5446
always_assert(num_comments < 1)
55-
my_retry(() -> post_comment!(api, repo,
56-
pr,
57-
_body;
58-
auth = auth))
47+
my_retry(() -> post_comment!(api, repo, pr, _body; auth=auth))
5948
end
6049
return nothing
6150
end

0 commit comments

Comments
 (0)