-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlatest-of1.reb
95 lines (92 loc) · 2.63 KB
/
latest-of1.reb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Rebol [
file: %latest-of.reb
date: 26-Mar-2019
Author: "Graham"
note: "web utility only"
]
idate-to-date: function [return: [date!] date [text!]] [
digit: charset [#"0" - #"9"]
alpha: charset [ #"A" - #"Z" #"a" - #"z" ]
parse date [
5 skip
copy day: 2 digit
space
copy month: 3 alpha
space
copy year: 4 digit
space
copy time: to space
space
copy zone: to end
] else [
fail ["Invalid idate:" date]
]
if zone = "GMT" [zone: copy "+0"]
to date! unspaced [day "-" month "-" year "/" time zone]
]
latest-of: function [os [tuple!]
/specific commit [text!]
][
if not specific [
parse to text! read to url! unspaced [https://metaeducation.s3.amazonaws.com/travis-builds/ os %/last_git_commit_short.js]
[{last_git_commit_short = '} copy commit to {'} to end]
]
root: https://s3.amazonaws.com/metaeducation/travis-builds/
; commit: copy/part rebol/commit 7
digit: charset [#"0" - #"6"]
inf?: if find form rebol/version "2.102.0.16.2" [
web: true
fsize-of: function [o [object!]][to integer! o/content-length]
fdate-of: function [o [object!]][
idate-to-date o/last-modified
]
pr: specialize 'replpad-write [html: true]
:js-head]
else [
web: false
fsize-of: function [o [object!]][o/size]
fdate-of: function [o [object!]][
o/date
]
pr: :print
:info?
]
os: form os
if parse os [ 1 digit "." 1 2 digit "." 1 2 digit end][
; looks like it might be valid OS
filename: unspaced ["r3-" commit]
debugfilename: append copy filename "-debug"
if find ["0.3.1" "0.3.40"] os [
append filename %.exe
append debugfilename %.exe
]
latest: 1-Jan-1980
print "searching ..."
if error? entrap [
filename.info: inf? filename.url: to-url unspaced [root os "/" filename]
print ["File size:" fsize-of filename.info "Date:" latest: fdate-of filename.info]
pr if web [
unspaced ["<a href=" filename.url ">" filename.url </a> <br/>]
] else [
form filename.url
]
][
print ["file:" filename "doesn't exist, it may still be being deployed" newline]
]
if error? entrap [
debugfilename.info: inf? debugfilename.url: to-url unspaced [root os "/" debugfilename]
print ["File size:" fsize-of debugfilename.info "Date:" fdate-of debugfilename.info]
pr if web [
unspaced ["<a href=" debugfilename.url ">" debugfilename.url </a> <br/>]
] else [
form debugfilename.url
]
][
if (difference now latest) < 2:00 [
print ["file:" debugfilename "doesn't exist, it may still be being deployed"]
]
]
] else [
print "Invalid OS"
]
]