Skip to content

Commit e6eb86b

Browse files
committed
zsh: add ghprdescpull alias
1 parent 33495e7 commit e6eb86b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

zsh/.zshrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,18 @@ alias gsha='git rev-parse HEAD'
198198
alias gct='git checkout trunk'
199199
alias gcmn='git checkout main'
200200
alias ghprdesc='gh pr edit --title "$(git log -n1 --format="%s")" --body "$(git log -n1 --format="%b")"'
201+
# sync-down: amend HEAD commit message from the current PR title/body
202+
function ghprdescpull() {
203+
local pr_json title body
204+
pr_json=$(gh pr view --json title,body) || return 1
205+
title=$(jq -r .title <<< "$pr_json")
206+
body=$(jq -r .body <<< "$pr_json")
207+
if [[ -n "$body" ]]; then
208+
git commit --amend -m "$title" -m "$body"
209+
else
210+
git commit --amend -m "$title"
211+
fi
212+
}
201213
# run 'gh pr create --fill'
202214
alias ghprfill='gh pr create --fill'
203215
# get the gh pr url for the current branch

0 commit comments

Comments
 (0)