Dotfiles/site-modules/core/files/oh-my-zsh/custom/prr.zsh
Ade Attwood 835d695ed0 feat(shell): add prr zsh plugin
This will use my directory structure to get the project namespace and
name for prr. This way we dont need to keep providing the extra info.
2023-08-21 10:30:24 +01:00

22 lines
760 B
Bash

# Gets the git project name "owner/repo" from the current directory. This uses
# the directory structure like the `GOPATH` this is aliased to `~s`. For
# example the directory would be `~/github.com/AdeAttwood/Dotfiles`, this would
# return `AdeAttwood/Dotfiles`.
function get_project() {
echo "$(basename "$(dirname "$PWD")")/$(basename "$PWD")"
}
# Gets the PR number from the current git repo and branch.
function get_pr_number() {
gh pr view --json=number --jq='.number'
}
alias prr-get='prr get "$(get_project)"/"$(get_pr_number)"'
alias prr-submit='prr submit "$(get_project)"/"$(get_pr_number)"'
alias prr-edit='$EDITOR ~/.local/share/prr/$(get_project)/$(get_pr_number).prr'
function prr-review() {
gh pr checkout "$1"
prr-get
prr-edit
}