mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-13 08:15:14 +02:00
fix(context): allow release git askpass env
This commit is contained in:
parent
3dca33ec11
commit
78ca891c0c
3 changed files with 31 additions and 2 deletions
|
|
@ -25,5 +25,5 @@ function sanitizedGitEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEn
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createSimpleGit(baseDir: string): SimpleGit {
|
export function createSimpleGit(baseDir: string): SimpleGit {
|
||||||
return simpleGit({ baseDir }).env(sanitizedGitEnv());
|
return simpleGit({ baseDir, unsafe: { allowUnsafeAskPass: true } }).env(sanitizedGitEnv());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,34 @@ describe('GitService', () => {
|
||||||
expect(config).toMatch(/\[gc]\n\s+autoDetach = false/);
|
expect(config).toMatch(/\[gc]\n\s+autoDetach = false/);
|
||||||
expect(config).toMatch(/\[maintenance]\n\s+autoDetach = false/);
|
expect(config).toMatch(/\[maintenance]\n\s+autoDetach = false/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('initializes when release automation sets GIT_ASKPASS', async () => {
|
||||||
|
const releaseEnvDir = await mkdtemp(join(tmpdir(), 'git-service-release-env-'));
|
||||||
|
const previousAskPass = process.env.GIT_ASKPASS;
|
||||||
|
process.env.GIT_ASKPASS = 'echo';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const releaseEnvService = new GitService({
|
||||||
|
storage: { configDir: releaseEnvDir, homeDir: releaseEnvDir },
|
||||||
|
git: {
|
||||||
|
userName: 'Test User',
|
||||||
|
userEmail: 'test@example.com',
|
||||||
|
bootstrapMessage: 'Initialize test config repo',
|
||||||
|
bootstrapAuthor: 'test-system',
|
||||||
|
bootstrapAuthorEmail: 'system@example.com',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(releaseEnvService.onModuleInit()).resolves.toBeUndefined();
|
||||||
|
} finally {
|
||||||
|
if (previousAskPass === undefined) {
|
||||||
|
delete process.env.GIT_ASKPASS;
|
||||||
|
} else {
|
||||||
|
process.env.GIT_ASKPASS = previousAskPass;
|
||||||
|
}
|
||||||
|
await rm(releaseEnvDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('commitFile `created` flag', () => {
|
describe('commitFile `created` flag', () => {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { type SimpleGit, simpleGit } from 'simple-git';
|
||||||
const SANITIZED_GIT_ENV_KEYS = [
|
const SANITIZED_GIT_ENV_KEYS = [
|
||||||
'EDITOR',
|
'EDITOR',
|
||||||
'GIT_ALTERNATE_OBJECT_DIRECTORIES',
|
'GIT_ALTERNATE_OBJECT_DIRECTORIES',
|
||||||
|
'GIT_ASKPASS',
|
||||||
'GIT_CONFIG',
|
'GIT_CONFIG',
|
||||||
'GIT_CONFIG_COUNT',
|
'GIT_CONFIG_COUNT',
|
||||||
'GIT_CONFIG_GLOBAL',
|
'GIT_CONFIG_GLOBAL',
|
||||||
|
|
@ -31,5 +32,5 @@ export function createSimpleGit(baseDir?: string): SimpleGit {
|
||||||
for (const key of SANITIZED_GIT_ENV_KEYS) {
|
for (const key of SANITIZED_GIT_ENV_KEYS) {
|
||||||
delete env[key];
|
delete env[key];
|
||||||
}
|
}
|
||||||
return simpleGit(baseDir).env(env);
|
return simpleGit({ baseDir, unsafe: { allowUnsafeAskPass: true } }).env(env);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue