38 lines
1.1 KiB
PowerShell
38 lines
1.1 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
$scriptDir = $PSScriptRoot
|
|
if ( [string]::IsNullOrWhiteSpace($scriptDir))
|
|
{
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
}
|
|
$root = (Resolve-Path -LiteralPath (Join-Path $scriptDir "..")).Path
|
|
Set-Location -LiteralPath $root
|
|
$origin = git remote get-url origin
|
|
$origin = $origin.TrimEnd("/")
|
|
$remoteRoot = $origin -replace "/[^/]+(\.git)?$", ""
|
|
$remoteRoot = $remoteRoot -replace "/[^/]+$", ""
|
|
echo "remoteRoot $remoteRoot"
|
|
|
|
function Fetch-Repo
|
|
{
|
|
param(
|
|
[string]$Repo,
|
|
[string]$Branch,
|
|
[string]$Dir
|
|
)
|
|
if (Test-Path -LiteralPath $Dir -PathType Container)
|
|
{
|
|
git -C $Dir rev-parse --is-inside-work-tree *> $null
|
|
git -C $Dir remote set-url origin $Repo
|
|
git -C $Dir fetch origin $Branch
|
|
git -C $Dir checkout $Branch
|
|
git -C $Dir pull --ff-only origin $Branch
|
|
}
|
|
else
|
|
{
|
|
git clone --branch $Branch --single-branch $Repo $Dir
|
|
}
|
|
}
|
|
|
|
Fetch-Repo "$remoteRoot/ae/build_infra" -Branch "master" "third_party/build_infra"
|
|
Fetch-Repo "$remoteRoot/ae/CPP_Core" -Branch "master" "third_party/CPP_Core"
|