@@ -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
1615end
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
4744function _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
5856end
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
8585end
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
101103end
102104
@@ -130,46 +132,50 @@ function set_git_identity(username, email)
130132 return nothing
131133end
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
147151end
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
228241end
0 commit comments