2
0
Fork 0
mirror of https://github.com/actions/checkout.git synced 2025-08-11 17:51:01 +00:00

try preserve local changes option

This commit is contained in:
Salman Muin Kayser Chishti 2025-08-11 12:21:31 +01:00
parent 9f265659d3
commit 45fe6460ed
6 changed files with 59 additions and 6 deletions

View file

@ -229,7 +229,15 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
// Checkout
core.startGroup('Checking out the ref')
await git.checkout(checkoutInfo.ref, checkoutInfo.startPoint)
if (settings.preserveLocalChanges) {
core.info('Attempting to preserve local changes during checkout')
// Use --merge to preserve local changes if possible
// This will fail if there are merge conflicts, but that's expected behavior
await git.checkout(checkoutInfo.ref, checkoutInfo.startPoint, ['--merge'])
} else {
// Use the default behavior with --force
await git.checkout(checkoutInfo.ref, checkoutInfo.startPoint)
}
core.endGroup()
// Submodules