11using Pkg
2- import Git
2+ Pkg. add ([" Git" , " GitHub" , " Dates" ])
3+ using Git, GitHub, Dates
34
4- const git = Git. git ()
5+ gh_token = ARGS [1 ]
6+ auth = GitHub. authenticate (gh_token)
57
8+ const git = Git. git ()
9+ date = Dates. format (now (), " yyyy-mm-dd" )
610benchpath = joinpath (@__DIR__ , " .." , " .." , " benchmarks" )
711
12+ # Get all the open PRs and their number
13+ gh_prs = GitHub. pull_requests (" SciML/SciMLBenchmarks" ; auth= auth)
14+ prs = Dict {String, Int64} ()
15+ for i in 1 : length (gh_prs[1 ])
16+ prs[gh_prs[1 ][i]. head. ref] = gh_prs[1 ][i]. number
17+ end
18+
19+ # Get all the branches from the repo
20+ gh_branches = GitHub. branches (" SciML/SciMLBenchmarks" ; auth= auth)
21+ branches = [gh_branches[1 ][i]. name for i in 1 : length (gh_branches[1 ])]
22+
823for dir in readdir (benchpath)
924 model_dir = joinpath (benchpath, dir)
1025 isdir (model_dir) || continue
@@ -15,9 +30,28 @@ for dir in readdir(benchpath)
1530 end
1631 manpath = (joinpath (benchpath, " Manifest.toml" ))
1732 if length (readlines (` git status . --porcelain` )) > 1
18- run (` git checkout -B $dir ` )
19- run (` $git add -A . :!$(manpath) ` )
20- run (` $git commit -m "Updated $(dir) "` )
21- run (` $git push --set-upstream origin $(dir) ` )
33+ if dir ∉ branches
34+ run (` git checkout -b $(dir) master` )
35+ run (` $git add -A . :!$(manpath) ` )
36+ run (` $git commit -m "Updated $(dir) on $(date) "` )
37+ run (` $git push --set-upstream origin $(dir) ` )
38+ else
39+ run (` $git fetch origin` )
40+ run (` $git checkout $(dir) ` )
41+ run (` $git pull -Xours` )
42+ run (` $git add -A . :!$(manpath) ` )
43+ run (` $git commit -m "Updated $(dir) on $(date) "` )
44+ run (` $git push` )
45+ end
46+ if dir ∉ keys (prs)
47+ params = Dict (
48+ " title" => " Updated $(dir) for benchmarks" ,
49+ " head" => " $(dir) " ,
50+ " base" => " master"
51+ )
52+ GitHub. create_pull_request (" SciML/SciMLBenchmarks" ; params= params, auth= auth)
53+ else
54+ GitHub. update_pull_request (" SciML/SciMLBenchmarks" , prs[dir]; auth= auth)
55+ end
2256 end
2357end
0 commit comments