dotfiles/bin/git-opr

27 lines
422 B
Plaintext
Raw Normal View History

#!/bin/bash
2019-10-22 09:50:54 +00:00
set -e
2019-10-22 09:50:54 +00:00
ensure_is_published() {
[[ ! $is_published ]] && git publish
}
2019-10-22 09:50:54 +00:00
is_published() {
echo $(git upstream)
}
2019-10-22 09:50:54 +00:00
open_or_build_pull_request() {
type gh &>/dev/null
2019-10-22 09:50:54 +00:00
if [ $? -ne 0 ]; then
echo "Error: gh command not found."
exit 1
fi
2019-10-22 09:50:54 +00:00
# Load an existing PR, or create a new one.
gh pr view --web || gh pr create --assignee opdavies --web
}
2019-10-22 09:50:54 +00:00
ensure_is_published
open_or_build_pull_request