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 / protocol / synapse / map / src / 75-publish.om

395 lines · 7579 bytes Raw Blame History
1note ======== new --publish: create the child on GitHub and open the parent's draft PR ========
2note Every step is one argv run as /usr/bin/env HOME=$HOME PATH=$HOME/.local/bin:/usr/bin:/bin ARGV...
3note (execprog: empty environment, no PATH search), with the child's stdout sent to stderr so stdout
4note stays JSONL. --dry-run prints {"argv":[...]} (and {"edit":..,"line":..} for the README step)
5note instead of running anything. The first failing step stops the run: {"ok":false,...}, exit 70.
6note Its globals, consts and texts are declared in 70-new.om: sm_new reads them, and omc needs a global,
7note const or text declared before its first use.
8
9note sm_cat: pool slice for text a + slice (o, n) + text b; length in SSLEN
10fn sm_cat a view uchar * o ulong n ulong b view uchar * to ulong
11s = get gst SPOOL
12z = sm_pt a
13z = sm_pcp o n
14z = sm_pt b
15put gst SSLEN sub get gst SPOOL s
16ret s
17end
18
19note sm_pkenv: start a packed argv with the env wrapper; returns the next offset
20fn sm_pkenv to ulong
21put gpk 0 0
22put gpk 1 0
23put gst SPKN 0
24p = sm_pktx 2 tenv
25k = sm_envkv thomee
26if eq k SNONE
27p = sm_pktx p tdefhome
28p = sm_pktx p tdefpath
29ret p
30end
31kn = get gst SSLEN
32p = sm_pkadd p k kn
33h = add k len thomee
34hn = sub kn len thomee
35q = sm_cat tpathk h hn tpathsfx
36p = sm_pkadd p q get gst SSLEN
37ret p
38end
39
40fn sm_pkg p ulong k ulong to ulong
41ret sm_pkadd p get gst k get gst add k 1
42end
43
44note sm_pkrun: run gpk (records up to offset p), stdout to stderr; exit status, 256 + signal, or 512
45fn sm_pkrun p ulong to ulong
46st = new uchar 4 0
47if ne get gst SOVF 0
48ret 512
49end
50r = sm_flush 1
51pid = fork
52if lt pid 0
53ret 512
54end
55if eq pid 0
56d = dupfd 2 1 0
57x = execprog gpk 0 p
58exit 127
59end
60w = waitpid int pid st 0 4 0
61if lt w 0
62ret 512
63end
64s = ulong get st 0
65if ne s 0
66ret add 256 and s 127
67end
68ret ulong get st 1
69end
70
71fn sm_oargv to void
72sm_ob 91
73n = get gst SPKN
74for i ulong n
75if ge i 3
76if gt i 3
77sm_ob 44
78end
79i2 = mul i 2
80ao = get garv i2
81al = get garv add i2 1
82sm_oq ao al
83end
84end
85sm_ob 93
86end
87
88note sm_step: run (or print) the packed argv; a failure prints the error record and exits 70
89fn sm_step k ulong p ulong to void
90if ne get gst SDRY 0
91sm_ob 123
92sm_ok tkargv
93sm_oargv
94sm_ob 125
95sm_ob 10
96ret
97end
98c = sm_pkrun p
99if ne c 0
100sm_ob 123
101sm_ok tkok
102sm_obool false
103sm_okc tkstep
104sm_on k
105sm_okc tkargv
106sm_oargv
107sm_okc tkstat
108sm_on c
109sm_ob 125
110sm_ob 10
111sm_die 70
112end
113end
114
115note git -C <slice k> ... prefix
116fn sm_pkgit k ulong to ulong
117p = sm_pkenv
118p = sm_pktx p tgit
119p = sm_pktx p tdashc
120ret sm_pkg p k
121end
122
123fn sm_pkid p ulong to ulong
124p = sm_pktx p tdashcc
125p = sm_pktx p tuname
126p = sm_pktx p tdashcc
127ret sm_pktx p tumail
128end
129
130note sm_pubset: slices used by the steps (child dir, owner/repo of parent, clone dir, branch, line)
131fn sm_pubset to void
132d = sm_apool get gst SNDI
133dn = get gst SSLEN
134put gst SCHO d
135put gst SCHL dn
136po = get gst SNPO
137q = sm_pfind po get gst SNPL 64
138put gst SPRO po
139put gst SPRL q
140c = sm_cat part tempty 0 0 d dn tparsfx
141put gst SCLO c
142put gst SCLL get gst SSLEN
143b = sm_cat tconn get gst SNNO get gst SNNL part tempty 0 0
144put gst SBRO b
145put gst SBRL get gst SSLEN
146w = sm_pfind po q 47
147f = get gst SPOOL
148z = sm_pcp po w
149sm_pb 47
150z = sm_pcp get gst SNNO get gst SNNL
151put gst SFNO f
152put gst SFNL sub get gst SPOOL f
153s = get gst SPOOL
154sm_pb 45
155sm_pb 32
156sm_pb 91
157z = sm_pcp get gst SNNO get gst SNNL
158z = sm_pt tr2
159z = sm_pcp f get gst SFNL
160z = sm_pt tp3
161z = sm_pcp get gst SNUO get gst SNUL
162put gst SLNO s
163put gst SLNL sub get gst SPOOL s
164end
165
166note sm_ishead: line at offset i of gfile starts with t
167fn sm_ishead i ulong n ulong t view uchar * to bool
168if gt add i len t n
169ret false
170end
171for j ulong len t
172if ne get gfile add i j get t j
173ret false
174end
175end
176ret true
177end
178
179note sm_rdapp: copy gfile (n bytes) to output, then append the Connected repos section and the line
180fn sm_rdapp n ulong to void
181for j ulong n
182sm_ob get gfile j
183end
184lastc = uchar 10
185if gt n 0
186lastc = get gfile sub n 1
187end
188if ne lastc 10
189sm_ob 10
190end
191sm_ot tconnhb
192sm_op get gst SLNO get gst SLNL
193sm_ob 10
194end
195
196note sm_rdins: copy gfile with the line inserted at the end of the section starting at h (scan stopped at i)
197fn sm_rdins h ulong i ulong n ulong to void
198jj = i
199if gt jj n
200jj = n
201end
202lo = add h len tconnh
203for it ulong jj
204if not and gt jj lo eq get gfile sub jj 1 10
205break
206end
207jj = sub jj 1
208end
209for k ulong jj
210sm_ob get gfile k
211end
212sm_ob 10
213sm_op get gst SLNO get gst SLNL
214for kk ulong sub n jj
215sm_ob get gfile add jj kk
216end
217end
218
219note sm_rdedit: add the README line under "## Connected repos" in the clone (section created if absent)
220fn sm_rdedit to void
221sm_pclr
222sm_ppool get gst SCLO get gst SCLL
223sm_pc 47
224sm_ptx treadme
225x = sm_rdfile
226if lt x 0
227sm_ob 123
228sm_ok tkok
229sm_obool false
230sm_okc tkedit
231q = sm_ppath
232sm_oq q get gst SSLEN
233sm_okc tkstat
234sm_on ulong sub 0 x
235sm_ob 125
236sm_ob 10
237sm_die 70
238end
239r = sm_flush 1
240n = get gst SFLEN
241h = SNONE
242i = ulong 0
243for it ulong n
244if ge i n
245break
246end
247if and eq h SNONE sm_ishead i n tconnh
248h = i
249else
250if and ne h SNONE and gt i h eq get gfile i 35
251break
252end
253end
254e = sm_pfind2 i n
255i = add e 1
256end
257if eq h SNONE
258sm_rdapp n
259else
260sm_rdins h i n
261end
262w = sm_wratom
263if lt w 0
264sm_err tnwrite
265wr = write 2 gpath 0 get gst SPLEN
266sm_errnl
267sm_die 70
268end
269end
270
271note sm_pfind2: offset of the next '\n' in gfile from i (n when none)
272fn sm_pfind2 i ulong n ulong to ulong
273if ge i n
274ret n
275end
276for k ulong sub n i
277j = add i k
278if eq get gfile j 10
279ret j
280end
281end
282ret n
283end
284
285fn sm_ppath to ulong
286s = get gst SPOOL
287for i ulong get gst SPLEN
288sm_pb get gpath i
289end
290put gst SSLEN sub get gst SPOOL s
291ret s
292end
293
294fn sm_publish to void
295sm_pubset
296p = sm_pkgit SCHO
297p = sm_pktx p tinit
298p = sm_pktx p tdashb
299p = sm_pktx p tmain
300sm_step 1 p
301p = sm_pkgit SCHO
302p = sm_pktx p tadd
303p = sm_pktx p tdasha
304sm_step 2 p
305p = sm_pkgit SCHO
306p = sm_pkid p
307p = sm_pktx p tcommit
308p = sm_pktx p tdashs
309p = sm_pktx p tdashm
310m = sm_cat tmsg1 get gst SNNO get gst SNNL tmsg1b
311p = sm_pkadd p m get gst SSLEN
312sm_step 3 p
313p = sm_pkenv
314p = sm_pktx p tgh
315p = sm_pktx p trepo
316p = sm_pktx p tcreate
317p = sm_pkg p SFNO
318p = sm_pktx p tpublic
319p = sm_pktx p tdescr
320p = sm_pkg p SNUO
321p = sm_pktx p tsource
322p = sm_pkg p SCHO
323p = sm_pktx p tpush
324sm_step 4 p
325p = sm_pkenv
326p = sm_pktx p tgit
327p = sm_pktx p tclone
328u = sm_cat tghurl get gst SPRO get gst SPRL part tempty 0 0
329p = sm_pkadd p u get gst SSLEN
330p = sm_pkg p SCLO
331sm_step 5 p
332p = sm_pkgit SCLO
333p = sm_pktx p tchkout
334p = sm_pktx p tdashb
335p = sm_pkg p SBRO
336sm_step 6 p
337if ne get gst SDRY 0
338sm_ob 123
339sm_ok tkedit
340e = sm_cat part tempty 0 0 get gst SCLO get gst SCLL tsreadme
341el = get gst SSLEN
342sm_oq e el
343sm_okc tkline
344sm_oq get gst SLNO get gst SLNL
345sm_ob 125
346sm_ob 10
347else
348sm_rdedit
349end
350p = sm_pkgit SCLO
351p = sm_pktx p tadd
352p = sm_pktx p treadme
353sm_step 8 p
354p = sm_pkgit SCLO
355p = sm_pkid p
356p = sm_pktx p tcommit
357p = sm_pktx p tdashs
358p = sm_pktx p tdashm
359m = sm_cat tmsg2 get gst SNNO get gst SNNL part tempty 0 0
360p = sm_pkadd p m get gst SSLEN
361sm_step 9 p
362p = sm_pkgit SCLO
363p = sm_pktx p tpush
364p = sm_pktx p tdashu
365p = sm_pktx p torigin
366p = sm_pkg p SBRO
367sm_step 10 p
368p = sm_pkenv
369p = sm_pktx p tgh
370p = sm_pktx p tpr
371p = sm_pktx p tcreate
372p = sm_pktx p tdraft
373p = sm_pktx p tdashr
374p = sm_pkadd p get gst SPRO get gst SPRL
375p = sm_pktx p thead
376p = sm_pkg p SBRO
377p = sm_pktx p ttitle
378t = sm_cat tconnt get gst SNNO get gst SNNL part tempty 0 0
379p = sm_pkadd p t get gst SSLEN
380p = sm_pktx p tbodyf
381b = sm_cat part tempty 0 0 get gst SCHO get gst SCHL tsppr
382p = sm_pkadd p b get gst SSLEN
383sm_step 11 p
384if eq get gst SDRY 0
385sm_ob 123
386sm_ok tkpub
387sm_obool true
388sm_okc tkrepo
389sm_oq get gst SFNO get gst SFNL
390sm_okc tkbr
391sm_oq get gst SBRO get gst SBRL
392sm_ob 125
393sm_ob 10
394end
395end