Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sovereign-intelligence/blob/main/tools/forkpush.om # sovereign-intelligence Front door to Drake Stapleton's sovereign stack. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `sovereign-intelligence / tools / forkpush.om` 585 lines ยท 14771 bytes Raw Blame History 1 om2 2 note tools/forkpush.om: the Radicle fork-push script generator, in pure seeded Omega. 3 note 4 note My personal GitHub account holds branches of stack work that never reached the projects' 5 note Radicle homes. stack/FORKS.tsv lists every one of them and where it goes. This program turns 6 note that manifest into the POSIX sh script that pushes the Radicle-bound ones home, so the script 7 note is generated from data, never written by hand. Build with the seed-born compiler: 8 note omc < tools/forkpush.om > forkpush && chmod +x forkpush 9 note { printf 'target x86linux\n'; cat tools/forkpush.om; } | omc-x86 > forkpush (native x86-64) 10 note Run: 11 note forkpush FORKS OUT 12 note FORKS read: stack/FORKS.tsv. The header line is exactly 13 note github TAB branch TAB head TAB commits TAB date TAB action TAB dest 14 note then one branch per line, exactly 7 TAB-separated fields: 15 note github owner/name, both parts of letters, digits, . _ - 16 note branch letters, digits, . _ / -; not starting with - or /, not ending with /, 17 note no .. and no // 18 note head 40 lowercase hex digits 19 note commits 1 to 20 decimal digits 20 note date YYYY-MM-DD, digits 21 note action radicle (dest is the project's RID, rad:z then letters and digits), 22 note private (dest is -) or si (dest is the path in this repository, the 23 note same characters and rules as a branch) 24 note A (github, branch) pair appears once. At most 4096 rows and 4 MiB. 25 note OUT written: the script. For every radicle row it fetches the branch from 26 note https://github.com/ into a Radicle working copy of the project, checks the 27 note fetched commit is the manifest head, and pushes it to Radicle as fork/. 28 note private and si rows become comment lines only. Every value is single-quoted in the 29 note script; validation guarantees none holds a quote. 30 note Exit 0 when OUT is written; 2 for the wrong number of arguments; 1 for any refusal, with one 31 note stderr line "forkpush: ..." and OUT not opened (the script is built in memory and written 32 note once, at the end). The output depends only on the input bytes: no clock, no environment. 33 34 note the manifest bytes and the script bytes 35 global inp uchar `4194304` 36 global inn ulong 1 37 global ob uchar `4194304` 38 global obn ulong 1 39 note the path named by the current argument 40 global pb uchar 4096 41 global pbn ulong 1 42 note rows, 16 cells each: offset and length of the 7 fields (cells 0..13), then the offset and 43 note length of the whole line (14, 15) 44 global row ulong 65536 45 global nrow ulong 1 46 note the action of each row: 1 radicle, 2 private, 3 si 47 global act ulong 4096 48 note rows per action: radicle, private, si 49 global cnt ulong 3 50 51 text tpre "forkpush: " 52 text tnl "\n" 53 text tusage "usage: forkpush FORKS OUT\n" 54 text targ "cannot read a command-line argument" 55 text topen "cannot open " 56 text tread "cannot read " 57 text tbig "manifest over the 4 MiB buffer: " 58 text twrite "cannot write " 59 text toverf "script over the 4 MiB buffer" 60 text thdr "github\tbranch\thead\tcommits\tdate\taction\tdest" 61 text tbhdr "header line is not github TAB branch TAB head TAB commits TAB date TAB action TAB dest: " 62 text tcols "row needs exactly 7 TAB-separated fields: " 63 text tmany "more than 4096 rows at: " 64 text tbgh "bad github owner/name: " 65 text tbbr "bad branch: " 66 text tbhd "head is not 40 lowercase hex digits: " 67 text tbcm "commits is not 1 to 20 decimal digits: " 68 text tbdt "date is not YYYY-MM-DD: " 69 text tbac "action is not radicle, private or si: " 70 text tbrid "radicle dest is not a RID (rad:z then letters and digits): " 71 text tbpr "private dest is not -: " 72 text tbsi "bad si dest path: " 73 text tdup "duplicate github and branch: " 74 text aradi "radicle" 75 text apriv "private" 76 text asi "si" 77 text tradz "rad:z" 78 text tdash "-" 79 text q1 "fp '" 80 text q2 "' '" 81 text q3 "'\n" 82 text c1 "# private, kept off Radicle: " 83 text c2 "# in this repository at " 84 text c3 ": " 85 text sp " " 86 text m1 "# Manifest: " 87 text m2 " to push to Radicle, " 88 text m3 " kept private, " 89 text m4 " in this repository.\n\n" 90 91 note the script, paragraph by paragraph 92 text h0 "#!/bin/sh\n# fork-push: push the fork-only branches of my personal GitHub forks to their Radicle projects.\n# Generated by tools/forkpush.om from stack/FORKS.tsv; do not edit by hand.\n#\n# For every stack/FORKS.tsv row whose action is radicle, it fetches the branch from\n# https://github.com// into a Radicle working copy of the project, checks that the\n# fetched commit is the head the manifest names, and only then pushes it to Radicle as\n# fork/. Rows kept private and rows already in this repository are listed below as\n# comments and are never fetched or pushed.\n#\n# Needs git, and rad authenticated as the project's delegate with its node running\n# (rad auth, rad node start). It refuses to run as root.\n# FP_DIR=path the one directory it creates and works in (default ./fork-push); each project\n# is cloned there once, into a directory named after its RID without rad:\n# Exit status: 0 every branch OK, 2 a fetched commit is not the manifest head,\n# 3 a clone, fetch or push failed (3 wins over 2).\n" 93 text h1 "set -eu\numask 022\n\nFP_DIR=\"${FP_DIR:-./fork-push}\"\nfp_say() { printf '%s\\n' \"$*\"; }\nfp_die() { printf 'fork-push: %s\\n' \"$*\" >&2; exit 1; }\n\nif [ \"$(id -u)\" = \"0\" ]; then fp_die \"refusing to run as root; run it as your own user\"; fi\ncommand -v git >/dev/null 2>&1 || fp_die \"git is required: https://git-scm.com\"\ncommand -v rad >/dev/null 2>&1 || fp_die \"rad is required: https://radicle.xyz\"\nmkdir -p -- \"$FP_DIR\"\ncd -- \"$FP_DIR\"\nfp_ok=0\nfp_bad=0\nfp_fail=0\n\n" 94 text h2 "fp() {\n fp_d=\"${1#rad:}\"\n if [ ! -d \"$fp_d\" ]; then\n if ! rad clone \"$1\" \"$fp_d\" /dev/null || true)\"\n if [ \"$fp_got\" != \"$4\" ]; then\n fp_say \"MISMATCH $1 fork/$3 manifest $4, fetched ${fp_got:-none}\"\n fp_bad=$((fp_bad + 1))\n return 0\n fi\n if git -C \"$fp_d\" push --quiet rad \"refs/heads/fork/$3:refs/heads/fork/$3\"