interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / apps / interplane-forge / collab / co6route.om

180 lines · 3091 bytes Raw Blame History
1note collab/co6route.om (ForgePatches): coroute, the collab entry point. Returns 0 when the path is not ours.
2note /<o>/<r>/patches[?state=] and /pulls (alias) list patches; /patches/<id> one patch; /patches/<id>.diff
3note (POST, compose/<cid> and issues|patches/new: Phase A, collab/co9form.om)
4note the raw diff; /pulls/<id> and /pull/<id> redirect (302) to /patches/<id>; /issues and /issues/<id>.
5note <id> is 4..40 lowercase hex, a prefix of exactly one COB id of this repo; anything else is 404.
6text tcpulls "/pulls"
7text tcpull "/pull"
8text tccompr "/compose"
9text tcnwr "new"
10global gcoff ulong 1
11fn coroute to long
12if ge get fridx 0 get fan 0
13ret 0
14end
15k = cosect
16if eq k 0
17ret 0
18end
19m = get fmeth 0
20if eq m 3
21ret copost k
22end
23if or eq m 1 eq m 2
24ret codisp k
25end
26ret 405
27end
28note cosegis t: frest starts with the segment t, followed by its end or a slash
29fn cosegis t view uchar * to bool
30if eq frstpre t false
31ret false
32end
33n = len t
34if eq n get frestl 0
35ret true
36end
37ret eq get frest n 47
38end
39note cosect: 1 /patches 2 /issues 3 /pulls 4 /pull, with the segment length in gcoff; 0 not ours
40fn cosect to ulong
41if cosegis tcpats
42put gcoff 0 len tcpats
43ret ulong 1
44end
45if cosegis tcisss
46put gcoff 0 len tcisss
47ret ulong 2
48end
49if cosegis tcpulls
50put gcoff 0 len tcpulls
51ret ulong 3
52end
53if cosegis tcpull
54put gcoff 0 len tcpull
55ret ulong 4
56end
57if cosegis tccompr
58put gcoff 0 len tccompr
59ret ulong 5
60end
61ret ulong 0
62end
63fn codisp k ulong to long
64o = get gcoff 0
65n = get frestl 0
66if or eq o n eq add o 1 n
67if eq k 4
68ret 404
69end
70if eq k 2
71ret colistx 2
72end
73ret colistx 1
74end
75if eq k 5
76ret cocget
77end
78a = add o 1
79if and le k 2 coseqat a n tcnwr
80if eq k 2
81ret conewpg 4
82end
83ret conewpg 5
84end
85if eq k 2
86if cocpid a n
87ret coissx
88end
89ret 404
90end
91if eq k 1
92ret codispp a n
93end
94if cocpid a n
95ret copulls
96end
97ret 404
98end
99note colistx kd, copatx, coissx: the JSON form (collab/coJjson.om) when the request asks for it, else
100note the HTML page, which names its own URL as the JSON alternate (fyalt)
101fn colistx kd ulong to long
102if fjwant
103ret cojlist kd
104end
105fyalt
106ret colist kd
107end
108fn copatx to long
109if fjwant
110ret cojpat
111end
112fyalt
113ret copatpg
114end
115fn coissx to long
116if fjwant
117ret cojiss
118end
119fyalt
120ret coisspg
121end
122fn codispp a ulong n ulong to long
123if qnends a n
124if cocpid a sub n 8
125ret qnraw
126end
127ret 404
128end
129if gt n add a len tcdsuf
130if codsuf n
131if cocpid a sub n len tcdsuf
132ret copraw
133end
134ret 404
135end
136end
137if cocpid a n
138ret copatx
139end
140ret 404
141end
142fn codsuf n ulong to bool
143s = sub n len tcdsuf
144for i ulong len tcdsuf
145if ne get frest add s i get tcdsuf i
146ret false
147end
148end
149ret true
150end
151note cocpid a b: frest[a,b) is 4..40 lowercase hex; copied into gcrq
152fn cocpid a ulong b ulong to bool
153if le b a
154ret false
155end
156n = sub b a
157if or lt n 4 gt n 40
158ret false
159end
160for i ulong n
161if eq cohexc get frest add a i false
162ret false
163end
164end
165for i ulong n
166put gcrq i get frest add a i
167end
168put gcrql 0 n
169ret true
170end
171note copulls: /pulls/<id> and /pull/<id> name the same page as /patches/<id>
172fn copulls to long
173put fkind 0 2
174flocrepo
175floct tcpatp
176for i ulong get gcrql 0 bound 40
177flocc get gcrq i
178end
179ret 302
180end