Conversation
Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Pull request overview
Adds an Azure DevOps scheduled “autosync” pipeline that mirrors dotnet/SqlClient GitHub commits into the internal ADO repo by force-updating a dedicated sync branch and creating/updating an active PR to internal/main.
Changes:
- Introduces a new ADO pipeline (
github-sync-pipeline.yml) scheduled to run daily and callable manually. - Adds a PowerShell sync script that fetches GitHub commits, force-pushes to an ADO sync branch, then creates/updates an ADO PR and posts an update thread.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| eng/pipelines/scripts/Sync-GitHubToAdo.ps1 | Implements Git fetch/force-push and ADO REST API PR create/update + comment posting. |
| eng/pipelines/github-sync-pipeline.yml | Defines the scheduled pipeline job that runs the sync script with System.AccessToken. |
6468b47 to
d1d4dd1
Compare
| # Check if the target branch exists and compare SHAs. | ||
| $targetRef = git rev-parse "origin/$TargetBranch" 2>&1 | ||
| $targetExists = ($LASTEXITCODE -eq 0) | ||
|
|
||
| if ($targetExists) { | ||
| Write-Host "Target HEAD : $targetRef" | ||
| } | ||
|
|
||
| # Check if the sync branch already exists in origin. | ||
| $syncRef = git rev-parse "origin/$SyncBranchName" 2>&1 | ||
| $syncBranchExists = ($LASTEXITCODE -eq 0) | ||
|
|
||
| if ($syncBranchExists -and $syncRef -eq $githubSha) { | ||
| Write-Host "" | ||
| Write-Host "Sync branch is already at GitHub HEAD. Nothing to do." | ||
| exit 0 |
There was a problem hiding this comment.
The script compares against origin/$TargetBranch and origin/$SyncBranchName without explicitly fetching those refs. Because the pipeline allows overriding targetBranch/githubBranch at queue time, this can mis-detect branch existence or produce an incorrect commit summary if the agent checkout doesn’t have the requested remote refs. Consider doing an explicit git fetch origin (or git fetch origin $TargetBranch / $SyncBranchName) before the git rev-parse checks.
| # Check if the target branch exists and compare SHAs. | ||
| $targetRef = git rev-parse "origin/$TargetBranch" 2>&1 | ||
| $targetExists = ($LASTEXITCODE -eq 0) | ||
|
|
||
| if ($targetExists) { | ||
| Write-Host "Target HEAD : $targetRef" | ||
| } | ||
|
|
||
| # Check if the sync branch already exists in origin. | ||
| $syncRef = git rev-parse "origin/$SyncBranchName" 2>&1 | ||
| $syncBranchExists = ($LASTEXITCODE -eq 0) | ||
|
|
There was a problem hiding this comment.
The PR/branch parameters are treated as short branch names (e.g., internal/main), but the script later prepends origin/ and refs/heads/ itself. If a caller passes a full ref (e.g., refs/heads/internal/main), git rev-parse "origin/$TargetBranch" and the REST targetRefName/sourceRefName values will be malformed. Consider validating/normalizing TargetBranch and SyncBranchName up front (strip a leading refs/heads/ or throw with a clear error).
Description
Introduces new pipeline that should trigger daily to open a PR or update a previously opened PR with latest commits from github's main branch.
Auto-Sync Pipeline build: https://dev.azure.com/SqlClientDrivers/ADO.Net/_build/results?buildId=148903&view=results
An exmaple PR is here: dotnet-sqlclient#7339