17 lines
958 B
JavaScript
17 lines
958 B
JavaScript
import {spawnSync} from 'node:child_process';
|
|
import {writeFileSync} from 'node:fs';
|
|
import {gitEnv} from '/home/jwoltje/.t3/worktrees/mosaic-stack/gander-row196/packages/seat/src/checkout.mjs';
|
|
const [root, mode] = process.argv.slice(2);
|
|
const env = gitEnv();
|
|
if ('GIT_TRACE2' in env || 'GIT_TRACE2_EVENT' in env) throw Error('gitEnv unexpectedly retained tracing');
|
|
const flags = mode === 'flagged' ? ['-c','maintenance.auto=false','-c','gc.auto=0'] : [];
|
|
function git(args) {
|
|
const r = spawnSync('git',[...flags,...args],{cwd:root,env,encoding:'utf8'});
|
|
if (r.status !== 0) throw Error(JSON.stringify({args,status:r.status,out:r.stdout,err:r.stderr}));
|
|
}
|
|
git(['init','-q']);
|
|
writeFileSync(root+'/fixture.txt','fixture commit\n');
|
|
git(['add','fixture.txt']);
|
|
git(['-c','user.name=Fixture','-c','[email protected]','commit','-qm','fixture']);
|
|
console.log(JSON.stringify({mode,commit:true,usesActualGitEnv:true,outerTraceScrubbed:true}));
|