Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,48 @@ New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
Write-Host "Created temp directory: $tempDir"

try {
# Clone the repository
Write-Host "Cloning azure-sdk-for-net repository..."
git clone "https://github.com/$RepoOwner/$RepoName.git" $tempDir
# Use sparse checkout to clone only the necessary files
# This significantly reduces disk space usage as azure-sdk-for-net is a very large repository
Write-Host "Setting up sparse checkout for azure-sdk-for-net repository..."

# Initialize empty git repository
git init $tempDir
if ($LASTEXITCODE -ne 0) {
throw "Failed to clone repository"
throw "Failed to initialize repository"
}

Push-Location $tempDir

# Add the remote
git remote add origin "https://github.com/$RepoOwner/$RepoName.git"
if ($LASTEXITCODE -ne 0) {
throw "Failed to add remote"
}

# Enable sparse checkout with cone mode for better performance
git sparse-checkout init --cone
if ($LASTEXITCODE -ne 0) {
throw "Failed to initialize sparse checkout"
}

# Set the sparse checkout patterns - only the directories we need
git sparse-checkout set eng/packages/http-client-csharp eng
if ($LASTEXITCODE -ne 0) {
throw "Failed to set sparse checkout patterns"
}

# Fetch only the main branch with depth 1
Write-Host "Fetching $BaseBranch branch with sparse checkout..."
git fetch --depth 1 origin $BaseBranch
if ($LASTEXITCODE -ne 0) {
throw "Failed to fetch repository"
}

# Checkout the fetched branch
git checkout $BaseBranch
if ($LASTEXITCODE -ne 0) {
throw "Failed to checkout $BaseBranch"
}

# Create a new branch
Write-Host "Creating branch $PRBranch..."
Expand Down
Loading