Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/util/git/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,26 @@ describe('util/git/index', { timeout: 10000 }, () => {
const res = (await repo.raw(['config', 'extra.clone.config'])).trim();
expect(res).toBe('test-extra-config-value');
});

it('should not pass extraCloneOpts to ls-remote when local repo exists', async () => {
const extraCloneOpts = {
'-c': 'extra.clone.config=test-extra-config-value',
};

await fs.emptyDir(tmpDir.path);
await git.initRepo({ url: origin.path, extraCloneOpts, fullClone: true });
await git.syncGit();

const rawSpy = vi.spyOn(SimpleGit.prototype, 'raw');

await git.initRepo({ url: origin.path, extraCloneOpts, fullClone: true });

expect(rawSpy).toHaveBeenCalledWith([
'ls-remote',
'--heads',
origin.path,
]);
});
});

describe('setGitAuthor()', () => {
Expand Down
4 changes: 3 additions & 1 deletion lib/util/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ async function fetchBranchCommits(preferUpstream = true): Promise<void> {
preferUpstream && config.upstreamUrl ? config.upstreamUrl : config.url;
logger.debug(`fetchBranchCommits(): url=${url}`);
const opts = ['ls-remote', '--heads', url];
if (config.extraCloneOpts) {
const localDir = GlobalConfig.get('localDir')!;
const repoExists = await fs.pathExists(upath.join(localDir, '.git/HEAD'));
if (config.extraCloneOpts && !repoExists) {
Comment thread
viceice marked this conversation as resolved.
Object.entries(config.extraCloneOpts).forEach((e) =>
// TODO: types (#22198)
opts.unshift(e[0], `${e[1]!}`),
Expand Down
Loading