Skip to content
Open
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
14 changes: 0 additions & 14 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,3 @@ export async function clone(

return cmd(additionalGitOptions, ...args);
}
export async function checkout(
ghRef: string,
additionalGitOptions: string[] = [],
...options: string[]
): Promise<string> {
core.debug(`Executing 'git checkout' to ref '${ghRef}' with token and options '${options.join(' ')}'`);

let args = ['checkout', ghRef];
if (options.length > 0) {
args = args.concat(options);
}

return cmd(additionalGitOptions, ...args);
}
13 changes: 11 additions & 2 deletions src/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,21 @@ async function writeBenchmarkToGitHubPagesWithRetry(

if (githubToken && !skipFetchGhPages && ghRepository) {
benchmarkBaseDir = './benchmark-data-repository';
await git.clone(githubToken, ghRepository, benchmarkBaseDir);
await git.clone(
githubToken,
ghRepository,
benchmarkBaseDir,
[],
'--branch',
ghPagesBranch,
'--single-branch',
'--depth',
'1',
);
rollbackActions.push(async () => {
await io.rmRF(benchmarkBaseDir);
});
extraGitArguments = [`--work-tree=${benchmarkBaseDir}`, `--git-dir=${benchmarkBaseDir}/.git`];
await git.checkout(ghPagesBranch, extraGitArguments);
} else if (!skipFetchGhPages && (!isPrivateRepo || githubToken)) {
await git.pull(githubToken, ghPagesBranch);
} else if (isPrivateRepo && !skipFetchGhPages) {
Expand Down
30 changes: 19 additions & 11 deletions test/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ok: (x: any, msg?: string) => asserts x = (x, msg) => {
}
};

type GitFunc = 'cmd' | 'push' | 'pull' | 'fetch' | 'clone' | 'checkout';
type GitFunc = 'cmd' | 'push' | 'pull' | 'fetch' | 'clone';
class GitSpy {
history: [GitFunc, unknown[]][];
pushFailure: null | string;
Expand Down Expand Up @@ -110,10 +110,6 @@ jest.mock('../src/git', () => ({
gitSpy.call('clone', args);
return '';
},
async checkout(...args: unknown[]) {
gitSpy.call('checkout', args);
return '';
},
}));

describe.each(['https://github.com', 'https://github.enterprise.corp'])('writeBenchmark() - %s', function (serverUrl) {
Expand Down Expand Up @@ -1088,12 +1084,18 @@ describe.each(['https://github.com', 'https://github.enterprise.corp'])('writeBe
},
gitServerUrl: serverUrl,
gitHistory: [
['clone', ['dummy token', 'https://github.com/user/other-repo', './benchmark-data-repository']],
[
'checkout',
'clone',
[
'dummy token',
'https://github.com/user/other-repo',
'./benchmark-data-repository',
[],
'--branch',
'gh-pages',
['--work-tree=./benchmark-data-repository', '--git-dir=./benchmark-data-repository/.git'],
'--single-branch',
'--depth',
'1',
],
],
[
Expand Down Expand Up @@ -1147,12 +1149,18 @@ describe.each(['https://github.com', 'https://github.enterprise.corp'])('writeBe
},
gitServerUrl: serverUrl,
gitHistory: [
['clone', ['dummy token', 'https://github.com/user/other-repo', './benchmark-data-repository']],
[
'checkout',
'clone',
[
'dummy token',
'https://github.com/user/other-repo',
'./benchmark-data-repository',
[],
'--branch',
'gh-pages',
['--work-tree=./benchmark-data-repository', '--git-dir=./benchmark-data-repository/.git'],
'--single-branch',
'--depth',
'1',
],
],
[
Expand Down