diff --git a/sync-skills.ps1 b/sync-skills.ps1 index c0af762..059839f 100644 --- a/sync-skills.ps1 +++ b/sync-skills.ps1 @@ -78,6 +78,15 @@ try { } Write-SyncLog -Level INFO -Message "Starting sync from '$sourceRoot'." + Invoke-Git -Arguments @('fetch', 'origin', 'main') + $remoteAhead = [int](& git -C $repositoryRoot rev-list --count 'main..origin/main') + if ($LASTEXITCODE -ne 0) { + throw 'Unable to determine whether the remote branch is ahead.' + } + if ($remoteAhead -gt 0) { + throw "Remote branch origin/main is ahead by $remoteAhead commit(s); merge it before syncing." + } + New-Item -ItemType Directory -Path $stagingRoot | Out-Null $sourceSkills = Get-ChildItem -LiteralPath $sourceRoot -Directory | Sort-Object Name