assert.ok(repositoryPath,'Expected repositoryPath to be defined');
assert.ok(repositoryUrl,'Expected repositoryUrl to be defined');
// Indicates whether to delete the directory contents
letremove=false;
// Check whether using git or REST API
if(!git){
@ -7263,6 +7291,7 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean) {
}
}
try{
core.startGroup('Removing previously created refs, to avoid conflicts');
// Checkout detached HEAD
if(!(yieldgit.isDetached())){
yieldgit.checkoutDetach();
@ -7277,8 +7306,10 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean) {
for(constbranchofbranches){
yieldgit.branchDelete(true,branch);
}
core.endGroup();
// Clean
if(clean){
core.startGroup('Cleaning the repository');
if(!(yieldgit.tryClean())){
core.debug(`The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For futher investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.`);
remove=true;
@ -7286,6 +7317,7 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean) {
elseif(!(yieldgit.tryReset())){
remove=true;
}
core.endGroup();
if(remove){
core.warning(`Unable to clean or reset the repository. The repository will be recreated instead.`);
@ -11,6 +13,10 @@ export async function prepareExistingDirectory(
repositoryUrl: string,
clean: boolean
):Promise<void>{
assert.ok(repositoryPath,'Expected repositoryPath to be defined')
assert.ok(repositoryUrl,'Expected repositoryUrl to be defined')
// Indicates whether to delete the directory contents
letremove=false
// Check whether using git or REST API
@ -38,6 +44,7 @@ export async function prepareExistingDirectory(
}
try{
core.startGroup('Removing previously created refs, to avoid conflicts')
// Checkout detached HEAD
if(!(awaitgit.isDetached())){
awaitgit.checkoutDetach()
@ -54,9 +61,11 @@ export async function prepareExistingDirectory(
for(constbranchofbranches){
awaitgit.branchDelete(true,branch)
}
core.endGroup()
// Clean
if(clean){
core.startGroup('Cleaning the repository')
if(!(awaitgit.tryClean())){
core.debug(
`The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For futher investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.`
@ -65,6 +74,7 @@ export async function prepareExistingDirectory(