@ -7223,6 +7267,7 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean) {
}
}
}
}
try{
try{
core.startGroup('Removing previously created refs, to avoid conflicts');
// Checkout detached HEAD
// Checkout detached HEAD
if(!(yieldgit.isDetached())){
if(!(yieldgit.isDetached())){
yieldgit.checkoutDetach();
yieldgit.checkoutDetach();
@ -7237,8 +7282,10 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean) {
for(constbranchofbranches){
for(constbranchofbranches){
yieldgit.branchDelete(true,branch);
yieldgit.branchDelete(true,branch);
}
}
core.endGroup();
// Clean
// Clean
if(clean){
if(clean){
core.startGroup('Cleaning the repository');
if(!(yieldgit.tryClean())){
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}'.`);
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;
remove=true;
@ -7246,10 +7293,17 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean) {
elseif(!(yieldgit.tryReset())){
elseif(!(yieldgit.tryReset())){
remove=true;
remove=true;
}
}
core.endGroup();
if(remove){
if(remove){
core.warning(`Unable to clean or reset the repository. The repository will be recreated instead.`);
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){
catch(error){
core.warning(`Unable to prepare the existing repository. The repository will be recreated instead.`);
core.warning(`Unable to prepare the existing repository. The repository will be recreated instead.`);
@ -38,6 +53,7 @@ export async function prepareExistingDirectory(
}
}
try{
try{
core.startGroup('Removing previously created refs, to avoid conflicts')
// Checkout detached HEAD
// Checkout detached HEAD
if(!(awaitgit.isDetached())){
if(!(awaitgit.isDetached())){
awaitgit.checkoutDetach()
awaitgit.checkoutDetach()
@ -54,9 +70,11 @@ export async function prepareExistingDirectory(
for(constbranchofbranches){
for(constbranchofbranches){
awaitgit.branchDelete(true,branch)
awaitgit.branchDelete(true,branch)
}
}
core.endGroup()
// Clean
// Clean
if(clean){
if(clean){
core.startGroup('Cleaning the repository')
if(!(awaitgit.tryClean())){
if(!(awaitgit.tryClean())){
core.debug(
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}'.`
`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())){
}elseif(!(awaitgit.tryReset())){
remove=true
remove=true
}
}
core.endGroup()
if(remove){
if(remove){
core.warning(
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){
}catch(error){
core.warning(
core.warning(
`Unable to prepare the existing repository. The repository will be recreated instead.`
`Unable to prepare the existing repository. The repository will be recreated instead.`