From c7bcd8ea21e29041a736f2465e0652e2345cca72 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Mon, 20 Mar 2023 15:49:33 +0800 Subject: [PATCH] UpdatE --- eng/common/scripts/TypeSpec-Project-Sync.ps1 | 29 ++------------------ 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/eng/common/scripts/TypeSpec-Project-Sync.ps1 b/eng/common/scripts/TypeSpec-Project-Sync.ps1 index f8656bc1d60..42cc3e344ac 100644 --- a/eng/common/scripts/TypeSpec-Project-Sync.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Sync.ps1 @@ -9,14 +9,8 @@ param ( $ErrorActionPreference = "Stop" . $PSScriptRoot/Helpers/PSModule-Helpers.ps1 +. $PSScriptRoot/Helpers/Sparse-Clone-Helpers.ps1 Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module -$sparseCheckoutFile = ".git/info/sparse-checkout" - -function AddSparseCheckoutPath([string]$subDirectory) { - if (!(Test-Path $sparseCheckoutFile) -or !((Get-Content $sparseCheckoutFile).Contains($subDirectory))) { - Write-Output $subDirectory >> .git/info/sparse-checkout - } -} function CopySpecToProjectIfNeeded([string]$specCloneRoot, [string]$mainSpecDir, [string]$dest, [string[]]$specAdditionalSubDirectories) { $source = "$specCloneRoot/$mainSpecDir" @@ -63,27 +57,8 @@ function GetGitRemoteValue([string]$repo) { return $result } -function InitializeSparseGitClone([string]$repo) { - git clone --no-checkout --filter=tree:0 $repo . - if ($LASTEXITCODE) { exit $LASTEXITCODE } - git sparse-checkout init - if ($LASTEXITCODE) { exit $LASTEXITCODE } - Remove-Item $sparseCheckoutFile -Force -} - function GetSpecCloneDir([string]$projectName) { - Push-Location $ProjectDirectory - try { - $root = git rev-parse --show-toplevel - } - finally { - Pop-Location - } - - $sparseSpecCloneDir = "$root/../sparse-spec/$projectName" - New-Item $sparseSpecCloneDir -Type Directory -Force | Out-Null - $createResult = Resolve-Path $sparseSpecCloneDir - return $createResult + return GetSparseCloneDir $ProjectDirectory $projectName "spec" } $typespecConfigurationFile = Resolve-Path "$ProjectDirectory/tsp-location.yaml"