mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-31 14:06:50 +01:00
/cso sets GIT_CONFIG_GLOBAL=/dev/null on every platform (Git for Windows 2.56 rejects NUL), shared by childEnvironment and the eval and producer Git environments, with a Windows-safe test that `git config --global --list` is empty. On macOS the local Docker socket resolves without opening it when Bun's realpathSync throws EOPNOTSUPP; Linux admission and the local-Unix-only rule are unchanged. /test-audit and /ship loop over file lists zsh does not word-split, with a static test against `for x in $VAR` in generated bash. /setup-deploy stops and writes nothing when nothing is deployed yet; /land-and-deploy runs a recorded command trigger only with explicit approval before claiming revision proof. TODOS.md records the open P2/P3 bugs by area, the Wave 9 parked items and the feature themes. Closes #3082. Adopts #3094, #3095, #3096 and #3109. Co-authored-by: marcode <244097767+vilano93@users.noreply.github.com> Co-authored-by: Nathan <196341+nathanshox@users.noreply.github.com> Co-authored-by: mikehasa <91774998+mikehasa@users.noreply.github.com> Co-authored-by: Andrey <95643518+Alfabit7@users.noreply.github.com>
57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import { afterAll, describe, expect, test } from 'bun:test';
|
|
import * as fs from 'node:fs';
|
|
import * as os from 'node:os';
|
|
import * as path from 'node:path';
|
|
import { spawnSync } from 'node:child_process';
|
|
import { childEnvironment, EMPTY_GLOBAL_GIT_CONFIG, executable } from '../lib/cso/process';
|
|
|
|
const roots: string[] = [];
|
|
afterAll(() => {
|
|
for (const root of roots.splice(0)) fs.rmSync(root, { recursive: true, force: true });
|
|
});
|
|
|
|
function homeWithGlobalConfig(): string {
|
|
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'cso-git-global-'));
|
|
roots.push(home);
|
|
fs.writeFileSync(path.join(home, '.gitconfig'), '[user]\n\tname = leaked-global\n');
|
|
fs.mkdirSync(path.join(home, '.config', 'git'), { recursive: true });
|
|
fs.writeFileSync(path.join(home, '.config', 'git', 'config'), '[user]\n\temail = leaked@xdg.invalid\n');
|
|
return home;
|
|
}
|
|
|
|
function gitConfig(home: string, env: Record<string, string>, args: string[]) {
|
|
return spawnSync(executable('git'), ['config', ...args], { cwd: home, env, encoding: 'utf8', timeout: 30_000 });
|
|
}
|
|
|
|
describe('CSO child Git reads no global or system config (#3082)', () => {
|
|
test('uses the /dev/null spelling on every platform and keeps NOSYSTEM', () => {
|
|
const env = childEnvironment(os.tmpdir());
|
|
expect(EMPTY_GLOBAL_GIT_CONFIG).toBe('/dev/null');
|
|
expect(env.GIT_CONFIG_GLOBAL).toBe('/dev/null');
|
|
expect(env.GIT_CONFIG_NOSYSTEM).toBe('1');
|
|
});
|
|
|
|
test('the fixture home is read when the override is absent', () => {
|
|
const home = homeWithGlobalConfig();
|
|
const { GIT_CONFIG_GLOBAL: _ignored, ...env } = childEnvironment(home);
|
|
const result = gitConfig(home, env, ['--global', '--list']);
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout).toContain('user.name=leaked-global');
|
|
});
|
|
|
|
test('git config --global --list is empty and exits 0 under the CSO environment', () => {
|
|
const home = homeWithGlobalConfig();
|
|
const result = gitConfig(home, childEnvironment(home), ['--global', '--list']);
|
|
expect(result.stderr).toBe('');
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout).toBe('');
|
|
});
|
|
|
|
test('neither the home nor the XDG config reaches the merged view', () => {
|
|
const home = homeWithGlobalConfig();
|
|
const result = gitConfig(home, childEnvironment(home), ['--list']);
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout).not.toContain('leaked');
|
|
});
|
|
});
|