@@ -222,8 +222,10 @@ export const GIT_USERNAME = 'x-access-token';
222222export const MANIFEST_PATH = '/tmp/manifests' ;
223223
224224export function createCloneScript ( repo : string , branch : string , sha ?: string ) : string {
225- const cloneCmd = `git clone -b ${ branch } https://\${GIT_USERNAME}:\${GIT_PASSWORD}@github.com/${ repo } .git /workspace` ;
226- const checkoutCmd = sha ? ` && cd /workspace && git checkout ${ sha } ` : '' ;
225+ const cloneCmd = `git clone --depth 1 --single-branch --progress -b ${ branch } https://\${GIT_USERNAME}:\${GIT_PASSWORD}@github.com/${ repo } .git /workspace` ;
226+ const checkoutCmd = sha
227+ ? ` && cd /workspace && git fetch --depth 1 --progress origin ${ sha } && git checkout ${ sha } `
228+ : '' ;
227229 return `${ cloneCmd } ${ checkoutCmd } ` ;
228230}
229231
@@ -234,9 +236,10 @@ export function createGitCloneContainer(repo: string, revision: string, gitUsern
234236 command : [ 'sh' , '-c' ] ,
235237 args : [
236238 `git config --global --add safe.directory /workspace && \
237- git clone https://\${GIT_USERNAME}:\${GIT_PASSWORD}@github.com/${ repo } .git /workspace && \
238- cd /workspace && \
239- git checkout ${ revision } ` ,
239+ git init /workspace && cd /workspace && \
240+ git remote add origin https://\${GIT_USERNAME}:\${GIT_PASSWORD}@github.com/${ repo } .git && \
241+ git fetch --depth 1 --progress origin ${ revision } && \
242+ git checkout FETCH_HEAD` ,
240243 ] ,
241244 env : [
242245 {
@@ -270,9 +273,10 @@ export function createRepoSpecificGitCloneContainer(
270273 command : [ 'sh' , '-c' ] ,
271274 args : [
272275 `git config --global --add safe.directory ${ targetDir } && \
273- git clone https://\${GIT_USERNAME}:\${GIT_PASSWORD}@github.com/${ repo } .git ${ targetDir } && \
274- cd ${ targetDir } && \
275- git checkout ${ revision } ` ,
276+ git init ${ targetDir } && cd ${ targetDir } && \
277+ git remote add origin https://\${GIT_USERNAME}:\${GIT_PASSWORD}@github.com/${ repo } .git && \
278+ git fetch --depth 1 --progress origin ${ revision } && \
279+ git checkout FETCH_HEAD` ,
276280 ] ,
277281 env : [
278282 {
0 commit comments