How to Quickly Check Contents of Pull Requests Before Merging with on Windows with GitHub CLI

The aim of this pageπŸ“ is to share a little PowerShell wrapper around GitHub CLI I am using daily

Pavol Kutaj
1 min readSep 12, 2022

The wrapper does 3 steps within a single command:

  1. Lists the description of a Pull Request
  2. Prints out the actual changes that were done
  3. Prompts of the actual merge should be done

I am using this as a trust but verify measure when performing releases/rollouts/deployments and I am given a particular Pull Request ID from developers. The prereq of course is that the GitHub CLI is up and running on your machine.

1. NOTES

  • Add this to your $profile
function mpr($pr_number) {
$pr_number | % {
Write-Host "β€”β€” THE DWARVES ARE CHECKING A PR DIFFs β€”β€”" -ForegroundColor Darkblue -BackgroundColor DarkYellow
Write-Host "β€”β€” VIEW β€”β€”" -ForegroundColor DarkCyan
gh pr view $_
Pause
Write-Host "β€”β€” DIFFs β€”β€”" -ForegroundColor DarkCyan
gh pr diff $_
Pause
Write-Host "β€”β€” MERGE β€”β€”" -ForegroundColor DarkCyan
gh pr merge $_
}
}
  • Navigate to the repo in terminal
  • run mpr <PR#>

2. LINKS

--

--

No responses yet