Files
renovate[bot] d1fd5df4bc build(deps): update dependency simple-git to v4 [security] (main) (#46781)
* build(deps): update dependency simple-git to v4 [security]

| datasource | package    | from   | to    |
| ---------- | ---------- | ------ | ----- |
| npm        | simple-git | 3.36.0 | 4.0.1 |

* fix(git): adapt to simple-git v4 environment guard

Allow the environment Renovate passes explicitly, use a dedicated instance for
authenticated submodule updates and allow url.insteadOf rewrites used by host
rules authentication.

* fix(deps): override @simple-git/argv-parser to v2.0.1

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: secustor <sebastian@poxhofer.at>
2026-10-08 07:51:45 +00:00

116 lines
3.3 KiB
TypeScript

import { logger } from '~test/util.ts';
import { GlobalConfig } from '../../config/global.ts';
import {
addGitConfigEnvironmentVariables,
setNoVerify,
simpleGitConfig,
} from './config.ts';
describe('util/git/config', () => {
beforeEach(() => {
GlobalConfig.reset();
});
it('uses "close" events, ignores "exit" events from child processes', () => {
expect(simpleGitConfig()).toEqual({
completion: { onClose: true, onExit: false },
config: ['core.quotePath=false'],
unsafe: {
allowUnsafeAskPass: true,
allowUnsafeSshCommand: true,
allowUnsafeConfigEnvCount: true,
allowUnsafeUrlRewrite: true,
},
});
});
it('uses timeout value from GlobalConfig', () => {
GlobalConfig.set({ gitTimeout: 50000 });
expect(simpleGitConfig()).toEqual({
completion: { onClose: true, onExit: false },
timeout: {
block: 50000,
},
config: ['core.quotePath=false'],
unsafe: {
allowUnsafeAskPass: true,
allowUnsafeSshCommand: true,
allowUnsafeConfigEnvCount: true,
allowUnsafeUrlRewrite: true,
},
});
});
it('throws', () => {
// @ts-expect-error -- testing invalid input
expect(() => setNoVerify(1)).toThrow(
'config error: gitNoVerify should be an array of strings',
);
});
it('appends entries without modifying the supplied environment', () => {
const environmentVariables = {
GIT_CONFIG_COUNT: '1',
GIT_CONFIG_KEY_0: 'existing-key',
GIT_CONFIG_VALUE_0: 'existing-value',
RANDOM_VARIABLE: 'random',
};
expect(
addGitConfigEnvironmentVariables(environmentVariables, [
{ key: 'first-key', value: 'first-value' },
{ key: 'second-key', value: 'second-value' },
]),
).toStrictEqual({
GIT_CONFIG_COUNT: '3',
GIT_CONFIG_KEY_0: 'existing-key',
GIT_CONFIG_KEY_1: 'first-key',
GIT_CONFIG_KEY_2: 'second-key',
GIT_CONFIG_VALUE_0: 'existing-value',
GIT_CONFIG_VALUE_1: 'first-value',
GIT_CONFIG_VALUE_2: 'second-value',
RANDOM_VARIABLE: 'random',
});
expect(environmentVariables).toStrictEqual({
GIT_CONFIG_COUNT: '1',
GIT_CONFIG_KEY_0: 'existing-key',
GIT_CONFIG_VALUE_0: 'existing-value',
RANDOM_VARIABLE: 'random',
});
});
it('supports repeated additions', () => {
const firstEnvironment = addGitConfigEnvironmentVariables({}, [
{ key: 'first-key', value: 'first-value' },
]);
expect(
addGitConfigEnvironmentVariables(firstEnvironment, [
{ key: 'second-key', value: 'second-value' },
]),
).toStrictEqual({
GIT_CONFIG_COUNT: '2',
GIT_CONFIG_KEY_0: 'first-key',
GIT_CONFIG_KEY_1: 'second-key',
GIT_CONFIG_VALUE_0: 'first-value',
GIT_CONFIG_VALUE_1: 'second-value',
});
});
it('ignores an invalid Git configuration count', () => {
expect(
addGitConfigEnvironmentVariables({ GIT_CONFIG_COUNT: 'invalid' }, [
{ key: 'new-key', value: 'new-value' },
]),
).toStrictEqual({
GIT_CONFIG_COUNT: '1',
GIT_CONFIG_KEY_0: 'new-key',
GIT_CONFIG_VALUE_0: 'new-value',
});
expect(logger.logger.warn).toHaveBeenCalledWith(
{ GIT_CONFIG_COUNT: 'invalid' },
`Found GIT_CONFIG_COUNT env variable, but could not parse the value to an integer. Ignoring it.`,
);
});
});