MCPcopy Index your code
hub / github.com/code-pushup/cli / simulateGitFetch

Function simulateGitFetch

testing/test-utils/src/lib/utils/git.ts:95–118  ·  view source on GitHub ↗
(git: SimpleGit)

Source from the content-addressed store, hash-verified

93}
94
95export async function simulateGitFetch(git: SimpleGit) {
96 let fetchHead: string = await git.branchLocal().then(resp => resp.current);
97
98 vi.spyOn(git, 'fetch').mockImplementation((...args) => {
99 fetchHead = (args as unknown as [string, string, string[]])[1];
100 return Promise.resolve({}) as Response<FetchResult>;
101 });
102
103 const originalDiffSummary = git.diffSummary.bind(git);
104 const originalDiff = git.diff.bind(git);
105
106 vi.spyOn(git, 'diffSummary').mockImplementation(args =>
107 originalDiffSummary(
108 (args as unknown as string[]).map(arg =>
109 arg === 'FETCH_HEAD' ? fetchHead : arg,
110 ),
111 ),
112 );
113 vi.spyOn(git, 'diff').mockImplementation(args =>
114 originalDiff(
115 (args as string[]).map(arg => (arg === 'FETCH_HEAD' ? fetchHead : arg)),
116 ),
117 );
118}

Callers 2

run.int.test.tsFile · 0.90
setupTestRepoFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected