@ -7223,6 +7267,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();
@ -7237,8 +7282,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;
@ -7246,10 +7293,17 @@ 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.`);
}
}
// Update to the preferred remote URL
if(remoteUrl!==preferredRemoteUrl){
core.startGroup('Updating the remote URL');
yieldgit.setRemoteUrl(preferredRemoteUrl);
core.endGroup();
}
}
catch(error){
core.warning(`Unable to prepare the existing repository. The repository will be recreated instead.`);
@ -38,6 +53,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 +70,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 +83,7 @@ export async function prepareExistingDirectory(
}elseif(!(awaitgit.tryReset())){
remove=true
}
core.endGroup()
if(remove){
core.warning(
@ -72,6 +91,13 @@ export async function prepareExistingDirectory(
)
}
}
// Update to the preferred remote URL
if(remoteUrl!==preferredRemoteUrl){
core.startGroup('Updating the remote URL')
awaitgit.setRemoteUrl(preferredRemoteUrl)
core.endGroup()
}
}catch(error){
core.warning(
`Unable to prepare the existing repository. The repository will be recreated instead.`