CD / tools /git /pull-scope.ps1
tkadkghdlf's picture
Sync from GitHub via hub-sync
f711f7f verified
Raw
History Blame Contribute Delete
590 Bytes
param(
[Parameter(Mandatory = $true)]
[string]$Branch,
[Parameter(Mandatory = $true)]
[string[]]$Scope
)
$ErrorActionPreference = "Stop"
$remoteRef = "origin/$Branch"
Write-Host "[pull-scope] fetch $remoteRef"
git fetch origin $Branch
if ($LASTEXITCODE -ne 0) {
throw "git fetch failed for branch: $Branch"
}
foreach ($path in $Scope) {
Write-Host "[pull-scope] apply $path from $remoteRef"
git restore --source $remoteRef --staged --worktree -- $path
if ($LASTEXITCODE -ne 0) {
throw "git restore failed for scope: $path"
}
}
Write-Host "[pull-scope] completed"