GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — platform-sdk-react/.github/scripts/signoff-token.test.mjs at main · youversion/platform-sdk-react Expand file tree/ Copy pathsignoff-token.test.mjsMore file actions 90 lines (76 loc) · 4.44 KB / Copy pathsignoff-token.test.mjsFile metadata and controls90 lines (76 loc) · 4.44 KB 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 // Drives signoffToken against real git trees. Each case mutates a scratch repo and asserts // whether the token moved, which is the property the gate relies on. import { execFileSync } from 'node:child_process' import { mkdtempSync, mkdirSync, writeFileSync, rmSync, renameSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { signoffToken } from '../../scripts/signoff-token.mjs' const repo = mkdtempSync(join(tmpdir(), 'signoff-token-')) const git = (...a) => execFileSync('git', a, { cwd: repo, encoding: 'utf8' }).trim() const commit = (msg) => { git('add', '-A'); git('-c', 'commit.gpgsign=false', 'commit', '-q', '-m', msg); return git('rev-parse', 'HEAD') } let base const tok = (head, v = '2.0.0') => signoffToken({ repoRoot: repo, base, head, nextVersion: v }) git('init', '-q', '-b', 'main'); git('config', 'user.email', 't@t'); git('config', 'user.name', 't') mkdirSync(join(repo, '.changeset')) writeFileSync(join(repo, '.changeset', 'a.md'), "---\n'p': major\n---\n\nbreak\n") writeFileSync(join(repo, '.changeset', 'README.md'), 'docs\n') writeFileSync(join(repo, 'src.txt'), 'code\n') writeFileSync(join(repo, '.changeset', 'config.json'), '{}\n') base = commit('base'); const baseTok = tok(base) const results = [] const check = (name, actual, expectSame) => results.push({ name, ok: (actual === baseTok) === expectSame, actual, expectSame }) writeFileSync(join(repo, 'src.txt'), 'code changed\n') check('ordinary code push keeps the token', tok(commit('code')), true) writeFileSync(join(repo, '.changeset', 'README.md'), 'docs edited\n') check('editing .changeset/README.md keeps the token', tok(commit('readme')), true) check('a version change replaces the token', tok(git('rev-parse', 'HEAD'), '2.0.1'), false) const afterDocs = git('rev-parse', 'HEAD') writeFileSync(join(repo, '.changeset', 'b.md'), "---\n'p': patch\n---\n\nfix\n") check('adding a changeset replaces the token', tok(commit('add changeset')), false) git('reset', '-q', '--hard', afterDocs) writeFileSync(join(repo, '.changeset', 'a.md'), "---\n'p': major\n---\n\nbreak differently\n") check('editing a changeset replaces the token', tok(commit('edit changeset')), false) git('reset', '-q', '--hard', afterDocs) rmSync(join(repo, '.changeset', 'a.md')) check('deleting a changeset replaces the token', tok(commit('delete changeset')), false) git('reset', '-q', '--hard', afterDocs) renameSync(join(repo, '.changeset', 'a.md'), join(repo, '.changeset', 'renamed.md')) check('renaming a changeset replaces the token', tok(commit('rename changeset')), false) // A tab in the path is why the blob line is split at the first tab only. Splitting on every // tab drops the file from the digest, and a dropped file cannot be seen to change, so the // discriminating assertion is that EDITING it moves the token. git('reset', '-q', '--hard', afterDocs) renameSync(join(repo, '.changeset', 'a.md'), join(repo, '.changeset', 'with\ttab.md')) const tabBefore = tok(commit('tab-named changeset')) writeFileSync(join(repo, '.changeset', 'with\ttab.md'), "---\n'p': major\n---\n\nbreak, reworded\n") const tabAfter = tok(commit('edit the tab-named changeset')) results.push({ name: 'editing a tab-named changeset replaces the token', ok: tabBefore !== tabAfter, }) git('reset', '-q', '--hard', afterDocs) writeFileSync(join(repo, '.changeset', 'config.json'), '{"fixed": []}\n') check('editing .changeset/config.json replaces the token', tok(commit('edit config')), false) // The branch has to be current with main before it merges, and every other PR brings its own // changeset. Merging main in must leave the signoff standing, so only this PR's changesets count. git('reset', '-q', '--hard', afterDocs) git('checkout', '-q', '-b', 'pr') writeFileSync(join(repo, '.changeset', 'mine.md'), "---\n'p': major\n---\n\nmine\n") const prTok = tok(commit('pr changeset')) git('checkout', '-q', 'main') git('reset', '-q', '--hard', afterDocs) writeFileSync(join(repo, '.changeset', 'theirs.md'), "---\n'p': patch\n---\n\ntheirs\n") commit('another PR lands on main') git('checkout', '-q', 'pr') git('-c', 'commit.gpgsign=false', 'merge', '-q', '--no-edit', 'main') const savedBase = base base = 'main' results.push({ name: 'merging a changeset in from main keeps the token', ok: tok(git('rev-parse', 'HEAD')) === prTok, }) base = savedBase rmSync(repo, { recursive: true, force: true }) for (const r of results) console.log(`${r.ok ? 'ok' : 'FAIL'}\t${r.name}`) process.exit(results.every((r) => r.ok) ? 0 : 1) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |