pass in the specified git branch ref when cloning a single branch

This commit is contained in:
Alan Crosswell
2021-01-17 18:16:19 -05:00
parent d5d435326d
commit a7c0da02e8
2 changed files with 4 additions and 1 deletions
+2 -1
View File
@@ -86,13 +86,14 @@ export class Git {
return git.commit({ fs, dir, message, author, committer });
}
async clone({ url, dir }: { url: string; dir: string }): Promise<void> {
async clone({ url, dir, ref }: { url: string; dir: string; ref?: string }): Promise<void> {
this.config.logger?.info(`Cloning repo {dir=${dir},url=${url}}`);
return git.clone({
fs,
http,
url,
dir,
ref,
singleBranch: true,
depth: 1,
onProgress: this.onProgressHandler(),
@@ -42,6 +42,7 @@ export class GitlabPreparer implements PreparerBase {
const parsedGitLocation = parseGitUrl(location);
const repositoryCheckoutUrl = parsedGitLocation.toString('https');
const ref = parsedGitLocation.toString('ref');
const tempDir = await fs.promises.mkdtemp(
path.join(workingDirectory, templateId),
);
@@ -61,6 +62,7 @@ export class GitlabPreparer implements PreparerBase {
await git.clone({
url: repositoryCheckoutUrl,
ref: ref,
dir: tempDir,
});