From a1f797f8e34825083e8a92401e7366d9dfffbcf8 Mon Sep 17 00:00:00 2001 From: Torgny Bjers Date: Sat, 4 May 2024 13:35:56 -0400 Subject: [PATCH] add custom command for checking out a GitHub PR branch from a list --- Custom-Commands-Compendium.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Custom-Commands-Compendium.md b/Custom-Commands-Compendium.md index a1aa878..9a345a2 100644 --- a/Custom-Commands-Compendium.md +++ b/Custom-Commands-Compendium.md @@ -116,6 +116,26 @@ customCommands: loadingText: "checking out PR" ``` +## List and Select GitHub PR for Checkout + +```yml +customCommands: + - key: "v" + context: "localBranches" + loadingText: "Checking out GitHub Pull Request..." + command: "gh pr checkout {{.Form.PullRequestNumber}}" + prompts: + - type: "menuFromCommand" + title: "Which PR do you want to check out?" + key: "PullRequestNumber" + command: >- + gh pr list --json number,title,headRefName,updatedAt + --template '{{`{{range .}}{{printf "#%v: %s - %s (%s)" .number .title .headRefName (timeago .updatedAt)}}{{end}}`}}' + filter: '#(?P[0-9]+): (?P.+) - (?P<ref_name>[^ ]+).*' + valueFormat: '{{.number}}' + labelFormat: '{{"#" | black | bold}}{{.number | white | bold}} {{.title | yellow | bold}}{{" [" | black | bold}}{{.ref_name | green}}{{"]" | black | bold}}' +``` + ## Opening git mergetool ```yml