File tree Expand file tree Collapse file tree 2 files changed +45
-7
lines changed Expand file tree Collapse file tree 2 files changed +45
-7
lines changed Original file line number Diff line number Diff line change 2020# Generate version index that is shown as root index page
2121cp util/gh-pages/versions.html out/index.html
2222
23- cd out
24- cat << -EOF | python - > versions.json
25- import os, json
26- print json.dumps([
27- dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
28- ])
29- EOF
23+ echo " Making the versions.json file"
24+ python ./util/versions.py out
3025
26+ cd out
3127# Now let's go have some fun with the cloned repo
3228git config user.name " GHA CI"
3329git config user.email " gha@ci.invalid"
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import json
4+ import os
5+ import sys
6+
7+ from lintlib import log
8+
9+
10+ def key (v ):
11+ if v == 'master' :
12+ return float ('inf' )
13+ if v == 'current' :
14+ return sys .maxsize
15+
16+ v = v .replace ('v' , '' ).replace ('rust-' , '' )
17+
18+ s = 0
19+ for i , val in enumerate (v .split ('.' )[::- 1 ]):
20+ s += int (val ) * 100 ** i
21+
22+ return s
23+
24+
25+ def main ():
26+ if len (sys .argv ) < 2 :
27+ print ("Error: specify output directory" )
28+ return
29+
30+ outdir = sys .argv [1 ]
31+ versions = [
32+ dir for dir in os .listdir (outdir ) if not dir .startswith ("." ) and os .path .isdir (os .path .join (outdir , dir ))
33+ ]
34+ versions .sort (key = key )
35+
36+ with open (os .path .join (outdir , "versions.json" ), "w" ) as fp :
37+ json .dump (versions , fp , indent = 2 )
38+ log .info ("wrote JSON for great justice" )
39+
40+
41+ if __name__ == "__main__" :
42+ main ()
You can’t perform that action at this time.
0 commit comments