Show actual branch name and separate PR row in repository information

Agent-Logs-Url: https://github.com/cmderdev/cmder/sessions/7ac9b75c-de48-4c0b-98db-108cc3423c0e

Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-12 00:29:30 +00:00
committed by GitHub
parent 0983e9b763
commit 55251f7cc3

View File

@@ -48,19 +48,35 @@ jobs:
$cmderVersion = Get-VersionStr $cmderVersion = Get-VersionStr
$buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") $buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
# Determine branch link (handle PR merge refs) # Determine branch and PR information
$branchName = "${{ github.ref_name }}" $refName = "${{ github.ref_name }}"
$headRef = "${{ github.head_ref }}"
$eventName = "${{ github.event_name }}"
$prNumber = $null
$actualBranchName = $refName
$branchLink = "" $branchLink = ""
if ($branchName -match '^(\d+)/(merge|head)$') { $prLink = ""
# This is a PR merge/head ref, link to the PR
# Check if this is a PR merge ref (e.g., "3061/merge")
if ($refName -match '^(\d+)/(merge|head)$') {
$prNumber = $Matches[1] $prNumber = $Matches[1]
$branchLink = "https://github.com/${{ github.repository }}/pull/$prNumber" # Use head_ref for the actual branch name if available
} elseif ("${{ github.event_name }}" -eq "pull_request") { if ($headRef) {
# This is a pull request event, link to the PR $actualBranchName = $headRef
$branchLink = "https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}" }
$branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
$prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
} elseif ($eventName -eq "pull_request") {
# This is a pull request event
$prNumber = "${{ github.event.pull_request.number }}"
if ($headRef) {
$actualBranchName = $headRef
}
$branchLink = "https://github.com/${{ github.repository }}/tree/$actualBranchName"
$prLink = "https://github.com/${{ github.repository }}/pull/$prNumber"
} else { } else {
# Regular branch, link to the branch tree # Regular branch, link to the branch tree
$branchLink = "https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}" $branchLink = "https://github.com/${{ github.repository }}/tree/$refName"
} }
$summary = @" $summary = @"
@@ -72,7 +88,8 @@ jobs:
| Property | Value | | Property | Value |
| --- | --- | | --- | --- |
| Repository | [``${{ github.repository }}``](https://github.com/${{ github.repository }}) | | Repository | [``${{ github.repository }}``](https://github.com/${{ github.repository }}) |
| Branch | [``$branchName``]($branchLink) | | Branch | [``$actualBranchName``]($branchLink) |
$(if ($prNumber) { "| Pull Request | [#$prNumber]($prLink) |" })
| Commit | [``${{ github.sha }}``](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) | | Commit | [``${{ github.sha }}``](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) |
| Actor | [@${{ github.actor }}](https://github.com/${{ github.actor }}) | | Actor | [@${{ github.actor }}](https://github.com/${{ github.actor }}) |
| Workflow | ``${{ github.workflow }}`` | | Workflow | ``${{ github.workflow }}`` |