-
Notifications
You must be signed in to change notification settings - Fork 2k
Automate branch setup and add verification in backport-changes skill #7222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lbussell
wants to merge
9
commits into
dotnet:nightly
Choose a base branch
from
lbussell:update-backport-skill
base: nightly
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+208
−29
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
253b00d
Correct eng directory
lbussell 68bec94
Improve backport-changes skill with verification and cleanup steps
lbussell c74b292
Remove specific distro reference
lbussell 1529c08
Add PR body template to backport-changes skill
lbussell 8644d65
Require draft PR and full-changeset approval in backport-changes skill
lbussell 8fafe25
Split confirm/PR into separate steps
lbussell 24ca06a
Add standardized working-branch step to backport-changes skill
lbussell 680272c
Add script/instructions for creating new working branch
lbussell ad8320c
Include branch date/timestamp
lbussell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| This pull request backports the following changes: | ||
|
|
||
| - #1234 | ||
| - #2345 |
50 changes: 50 additions & 0 deletions
50
.github/skills/backport-changes/scripts/Get-BackportDiff.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/usr/bin/env pwsh | ||
|
|
||
| # Shows the file-level diff between HEAD and the nightly branch on the public | ||
| # (GitHub) remote. Run this from your backport working branch (with cherry-picks | ||
| # applied and committed) to verify the backport: every reported difference should | ||
| # be an expected divergence (see SKILL.md). Investigate anything that is not. | ||
| # The working tree must be clean. | ||
|
|
||
| . "$PSScriptRoot/../../shared/GitHelpers.ps1" | ||
|
|
||
| # Detect the public (GitHub) remote so we can fetch and diff against its nightly. | ||
| $gitHubRemote = Get-PublicRemoteName | ||
|
|
||
| # Require a clean working tree so that all cherry-picks and regenerated files are | ||
| # committed. This lets us diff HEAD (including new files) rather than the working | ||
| # tree, which would miss untracked files. | ||
| $status = git status --porcelain | ||
| if (-not [string]::IsNullOrWhiteSpace($status)) { | ||
| throw "Working tree is not clean. Commit or stash your changes before verifying the backport, then re-run this script." | ||
| } | ||
|
|
||
| Write-Host "Fetching latest from '$gitHubRemote'..." | ||
| git fetch $gitHubRemote 2>&1 | Out-Null | ||
|
|
||
| $nightlyRef = "$gitHubRemote/nightly" | ||
| if (-not (git rev-parse --verify --quiet "$nightlyRef")) { | ||
| throw "Branch '$nightlyRef' was not found on remote '$gitHubRemote'." | ||
| } | ||
|
|
||
| Write-Host "" | ||
| Write-Host "# Backport verification diff" | ||
| Write-Host "" | ||
| Write-Host "Comparing HEAD against nightly on the public remote." | ||
| Write-Host "" | ||
| Write-Host "- Nightly: ``$nightlyRef``" | ||
| Write-Host "" | ||
| Write-Host "Every difference below should be an expected divergence (see SKILL.md)." | ||
| Write-Host "Investigate anything that is not." | ||
| Write-Host "" | ||
| Write-Host "## Changed files (HEAD vs nightly)" | ||
| Write-Host "" | ||
|
|
||
| $nameStatus = git diff --name-status "$nightlyRef" HEAD | ||
| if ([string]::IsNullOrWhiteSpace($nameStatus)) { | ||
| Write-Host "_No differences._" | ||
| } else { | ||
| Write-Host '```' | ||
| Write-Host ($nameStatus -join "`n") | ||
| Write-Host '```' | ||
| } |
55 changes: 55 additions & 0 deletions
55
.github/skills/backport-changes/scripts/New-BackportBranch.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #!/usr/bin/env pwsh | ||
|
|
||
| # Determines the latest public release branch and creates a working branch for | ||
| # backporting based on it. Combines steps 1 and 2 of the backport workflow: | ||
| # detect the public remote, fetch it, find the latest release branch, and create | ||
| # a `backport-<release>` branch off its up-to-date tip. | ||
|
|
||
| [CmdletBinding()] | ||
| param( | ||
| # Optional release branch override (e.g. "release/2026-05B"). Defaults to the | ||
| # most recently created public release branch. | ||
| [string] $ReleaseBranch | ||
| ) | ||
|
|
||
| . "$PSScriptRoot/../../shared/GitHelpers.ps1" | ||
|
|
||
| # Require a clean working tree so uncommitted changes are not carried onto the | ||
| # new branch. | ||
| $status = git status --porcelain | ||
| if (-not [string]::IsNullOrWhiteSpace($status)) { | ||
| throw "Working tree is not clean. Commit or stash your changes before creating the backport branch." | ||
| } | ||
|
|
||
| if ([string]::IsNullOrWhiteSpace($ReleaseBranch)) { | ||
| # Get-LatestPublicReleaseBranch resolves the public remote, fetches it, and | ||
| # returns a remote-qualified ref (e.g. "upstream/release/2026-06B"). | ||
| $startPoint = Get-LatestPublicReleaseBranch | ||
| Write-Host "Latest public release branch: $startPoint" | ||
| } else { | ||
| $remote = Get-PublicRemoteName | ||
| Write-Host "Fetching latest from '$remote'..." | ||
| git fetch $remote 2>&1 | Out-Null | ||
| $startPoint = "$remote/$ReleaseBranch" | ||
| } | ||
|
|
||
| if (-not (git rev-parse --verify --quiet "$startPoint")) { | ||
| throw "Start point '$startPoint' was not found on the public remote." | ||
| } | ||
|
|
||
| $releaseName = $startPoint -replace '^.*release/', '' | ||
| # Include a timestamp so re-running the skill always produces a distinct branch name. | ||
| $timestamp = Get-Date -Format 'yyyyMMdd-HHmmss' | ||
| $workingBranch = "backport-$releaseName-$timestamp" | ||
|
|
||
| if (git rev-parse --verify --quiet "refs/heads/$workingBranch") { | ||
| throw "Branch '$workingBranch' already exists. Delete it or check it out before re-running." | ||
| } | ||
|
|
||
| # Use --no-track so the working branch does not adopt the public release branch | ||
| # as its upstream. | ||
| git switch --no-track -c $workingBranch $startPoint | ||
|
|
||
| Write-Host "" | ||
| Write-Host "Created working branch '$workingBranch' based on '$startPoint'." | ||
| Write-Host "Next: get backport candidates with scripts/Get-BackportPRs.ps1." |
20 changes: 20 additions & 0 deletions
20
.github/skills/backport-changes/scripts/Remove-BackportLabels.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/env pwsh | ||
|
|
||
| # Removes the 'needs-backport' label from the given pull requests in | ||
| # dotnet/dotnet-docker. Run this after successfully backporting changes to clear | ||
| # the label from PRs that have been handled. | ||
|
|
||
| param( | ||
| [Parameter(Mandatory = $true)] | ||
| [int[]] $PRs | ||
| ) | ||
|
|
||
| $label = "needs-backport" | ||
|
|
||
| foreach ($pr in $PRs) { | ||
| Write-Host "Removing '$label' from #$pr..." | ||
| gh pr edit $pr --repo dotnet/dotnet-docker --remove-label $label | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Warning "Failed to remove '$label' from #$pr." | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #!/usr/bin/env pwsh | ||
|
|
||
| # Shared git helpers for the release/backport skills. Dot-source this file: | ||
| # . "$PSScriptRoot/GitHelpers.ps1" | ||
|
|
||
| # Finds the single git remote whose URL matches the given pattern. | ||
| function Get-RemoteName { | ||
| param( | ||
| [Parameter(Mandatory = $true)] | ||
| [string] $UrlPattern | ||
| ) | ||
|
|
||
| $matchingRemotes = @(git remote | Where-Object { | ||
| $remoteName = $_ | ||
| $remoteUrl = git remote get-url $remoteName 2>$null | ||
| $remoteUrl -match $UrlPattern | ||
| }) | ||
|
|
||
| if ($matchingRemotes.Count -eq 0) { | ||
| throw "Unable to find a remote with a URL matching '$UrlPattern'." | ||
| } | ||
|
|
||
| if ($matchingRemotes.Count -gt 1) { | ||
| throw "Found multiple remotes with URLs matching '$UrlPattern': $($matchingRemotes -join ', ')." | ||
| } | ||
|
|
||
| return $matchingRemotes[0] | ||
| } | ||
|
|
||
| # Finds the public (GitHub dotnet) remote. | ||
| function Get-PublicRemoteName { | ||
| return Get-RemoteName -UrlPattern 'github\.com[:/]dotnet/' | ||
| } | ||
|
|
||
| # Fetches the public remote and returns the most recently created public release | ||
| # branch as a remote-qualified ref (e.g. "upstream/release/2026-06B"). The remote | ||
| # prefix is kept intentionally so callers use the remote-tracking branch rather | ||
| # than a possibly-stale local branch. | ||
| function Get-LatestPublicReleaseBranch { | ||
| $remote = Get-PublicRemoteName | ||
| git fetch $remote 2>&1 | Out-Null | ||
|
|
||
| $branch = git branch -r --list "$remote/release/*" --sort=-creatordate ` | ||
| | Select-Object -First 1 | ||
|
|
||
| if ([string]::IsNullOrWhiteSpace($branch)) { | ||
| throw "No release branches found on remote '$remote'." | ||
| } | ||
|
|
||
| return $branch.Trim() | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are failures ignored here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an AI-ism... let me comb over the scripts more carefully and then I'll re-request review.