mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
fix(git): simple-git use clone rather than exit (#12092)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
This commit is contained in:
parent
4327845702
commit
3d67812fea
6 changed files with 27 additions and 5 deletions
|
@ -7,6 +7,7 @@ import { ExternalHostError } from '../../types/errors/external-host-error';
|
|||
import * as memCache from '../../util/cache/memory';
|
||||
import * as packageCache from '../../util/cache/package';
|
||||
import { privateCacheDir, readFile } from '../../util/fs';
|
||||
import { simpleGitConfig } from '../../util/git/config';
|
||||
import { Http } from '../../util/http';
|
||||
import * as cargoVersioning from '../../versioning/cargo';
|
||||
import type { GetReleasesConfig, Release, ReleaseResult } from '../types';
|
||||
|
@ -159,7 +160,7 @@ async function fetchRegistryInfo(
|
|||
clonePath = join(privateCacheDir(), cacheDirFromUrl(url));
|
||||
logger.info({ clonePath, registryUrl }, `Cloning private cargo registry`);
|
||||
|
||||
const git = Git();
|
||||
const git = Git(simpleGitConfig());
|
||||
const clonePromise = git.clone(registryUrl, clonePath, {
|
||||
'--depth': 1,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import simpleGit from 'simple-git';
|
||||
import * as packageCache from '../../util/cache/package';
|
||||
import { simpleGitConfig } from '../../util/git/config';
|
||||
import { getRemoteUrlWithToken } from '../../util/git/url';
|
||||
import * as semver from '../../versioning/semver';
|
||||
import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types';
|
||||
|
@ -17,7 +18,7 @@ export async function getRawRefs(
|
|||
{ lookupName }: GetReleasesConfig,
|
||||
hostType: string
|
||||
): Promise<RawRefs[] | null> {
|
||||
const git = simpleGit();
|
||||
const git = simpleGit(simpleGitConfig());
|
||||
const cacheNamespace = 'git-raw-refs';
|
||||
|
||||
const cachedResult = await packageCache.get<RawRefs[]>(
|
||||
|
|
|
@ -4,6 +4,7 @@ import upath from 'upath';
|
|||
import { getGlobalConfig } from '../../config/global';
|
||||
import * as datasourceGitRefs from '../../datasource/git-refs';
|
||||
import { logger } from '../../logger';
|
||||
import { simpleGitConfig } from '../../util/git/config';
|
||||
import { getHttpUrl, getRemoteUrlWithToken } from '../../util/git/url';
|
||||
import type { ExtractConfig, PackageFile } from '../types';
|
||||
import { GitModule } from './types';
|
||||
|
@ -14,7 +15,7 @@ async function getUrl(
|
|||
submoduleName: string
|
||||
): Promise<string> {
|
||||
const path = (
|
||||
await Git().raw([
|
||||
await Git(simpleGitConfig()).raw([
|
||||
'config',
|
||||
'--file',
|
||||
gitModulesPath,
|
||||
|
|
9
lib/util/git/config.spec.ts
Normal file
9
lib/util/git/config.spec.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { simpleGitConfig } from './config';
|
||||
|
||||
describe('util/git/config', () => {
|
||||
it('uses "close" events, ignores "exit" events from child processes', () => {
|
||||
expect(simpleGitConfig()).toEqual({
|
||||
completion: { onClose: true, onExit: false },
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import is from '@sindresorhus/is';
|
||||
import { SimpleGitOptions } from 'simple-git';
|
||||
|
||||
export const enum GitNoVerifyOption {
|
||||
Commit = 'commit',
|
||||
|
@ -21,3 +22,12 @@ export function setNoVerify(value: GitNoVerifyOption[]): void {
|
|||
export function getNoVerify(): GitNoVerifyOption[] {
|
||||
return noVerify;
|
||||
}
|
||||
|
||||
export function simpleGitConfig(): Partial<SimpleGitOptions> {
|
||||
return {
|
||||
completion: {
|
||||
onClose: true,
|
||||
onExit: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import { ExternalHostError } from '../../types/errors/external-host-error';
|
|||
import { GitOptions, GitProtocol } from '../../types/git';
|
||||
import { Limit, incLimitedValue } from '../../workers/global/limits';
|
||||
import { parseGitAuthor } from './author';
|
||||
import { GitNoVerifyOption, getNoVerify } from './config';
|
||||
import { GitNoVerifyOption, getNoVerify, simpleGitConfig } from './config';
|
||||
import { configSigningKey, writePrivateKey } from './private-key';
|
||||
|
||||
export { GitNoVerifyOption, setNoVerify } from './config';
|
||||
|
@ -186,7 +186,7 @@ export async function initRepo(args: StorageConfig): Promise<void> {
|
|||
config.additionalBranches = [];
|
||||
config.branchIsModified = {};
|
||||
const { localDir } = getGlobalConfig();
|
||||
git = Git(localDir);
|
||||
git = Git(localDir, simpleGitConfig());
|
||||
gitInitialized = false;
|
||||
await fetchBranchCommits();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue