kunibert
All repositories: gitoria
3.0 KB
$mode = 'static'import { run } from 'hl:proc'import { mkDir, writeFile, exists, remove, realPath, readFile } from 'hl:fs'import { toBase64 } from 'hl:crypto'import { require } from './review-output.hl'// ONE place for the remote ref names (gitoria will confirm them) and the limits.prHeadRemote = (Number n) => { return 'refs/pull/' + n + '/head' }prHeadLocal = (Number n) => { return 'refs/kunibert/pr/' + n }baseRemote = (String base) => { return 'refs/heads/' + base }baseLocal = (String base) => { return 'refs/kunibert/base/' + base }maxDiffBytes = 400000fetchTimeout = 120// Remote URL -> one URL-safe directory name.repoKey = (String url) => { return encodeURIComponent(url).replaceAll('_', '_5F').replaceAll('%', '_').replaceAll('.', '_2e') }// The ONLY place that knows the token. It goes into the environment of the git child (http.extraHeader through// GIT_CONFIG_COUNT): never the repo config, the URL, argv or a log. Null token file -> no extra environment.authEnv = (String tokenFile) => {if (tokenFile == null) { return {} }token = readToken(tokenFile)return { GIT_CONFIG_COUNT = '1', GIT_CONFIG_KEY_0 = 'http.extraHeader', GIT_CONFIG_VALUE_0 = 'Authorization: Basic ' + toBase64('app:' + token), GIT_TERMINAL_PROMPT = '0' }}readToken = (String file) => {lines = readFile(file).split('\n')token = lines[0].trim()require(token != '', 'token file is empty')return token}gitIn = (String dir, Hybrid argv, Hybrid env = null, Number timeout = 30) => {r = run(['git'] + argv, { cwd = dir, env = env, timeout = timeout })require(r.exit == 0, 'git failed (' + r.exit + '): ' + r.stderr.join(' '))return r.lines}// Bare cache repo for a remote, created on first use.cacheRepo = (String data, String url) => {mkDir(data + '/git')path = realPath(data) + '/git/' + repoKey(url) + '.git'if (!exists(path + '/HEAD')) { gitIn(realPath(data) + '/git', ['init', '--bare', '--quiet', path]) }return path}// Fetch only the two refs of a job, forced, no tags.fetchRefs = (String cache, String url, Number pr, String base, String tokenFile) => {gitIn(cache, ['fetch', '--quiet', '--no-tags', '--force', url, '+' + prHeadRemote(pr) + ':' + prHeadLocal(pr), '+' + baseRemote(base) + ':' + baseLocal(base)], authEnv(tokenFile), fetchTimeout)}// Fresh detached worktree of a commit at <data>/work/<key>/<pr>. A leftover from a crashed run is removed first.worktreePath = (String data, String url, Number pr) => { return realPath(data) + '/work/' + repoKey(url) + '/' + pr }addWorktree = (String cache, String path, String sha) => {removeWorktree(cache, path)mkDir(path + '/..')gitIn(cache, ['worktree', 'add', '--detach', '--force', path, sha])}removeWorktree = (String cache, String path) => {if (exists(path)) { run(['git', 'worktree', 'remove', '--force', path], { cwd = cache, timeout = 30 }) }if (exists(path)) { run(['rm', '-rf', path], { timeout = 30 }) }run(['git', 'worktree', 'prune'], { cwd = cache, timeout = 30 })return !exists(path)}
Branches
Latest commits
- bb0976acrecords: hycon PR 259 design findingmre
- 5c637c24records: hycon PR 259 false tool errormre
- a344c406log: routger 132 reviewedmre
- 56e70dcbrecords: review time limit 1800 s (routger 132)mre
- c3a304c5Merge branch 'job-timeout' into mainKunibert
- 402bfeb0|||PR runner: the model run uses the job's time limit (jobTimeoutSeconds), not a fixed 900 smre
- 8d34ca33records: repo rename (gitoria#53)mre
- 1e05cb3fMerge branch 'repo-rename' into mainKunibert
- 6ee0d2e9|||PR intake: match a delivery by repo.id and signature, not URLs (gitoria#53 rename)mre
- 900ffcd4status: routgermre
- 59b0b793log: routger merge waitmre
- e52f094alog: routger intake check (hycon#122)mre
- f979027frecords: design rule livemre
- 71efaf84Merge branch 'design-guard' into mainKunibert
- c0656581|||PR Flag removal of a documented design as major unless his recorded yes is linked; rules version 5mre
- 901cdd75records: L10 update 2 livemre
- 4a68016bMerge branch 'hl-standard-l10b' into mainKunibert
- 246d0f30|||PR HL-STANDARD L10 update (hybriel ab293e5a), rules version 4mre
- 1aa4d64crecords: HL-STANDARD L10 update livemre
- 2b04c240Merge branch 'hl-standard-l10' into mainKunibert