Skip to content

Commit

Permalink
[scripts] ,gh-create-pr: simplify pr creation
Browse files Browse the repository at this point in the history
  • Loading branch information
meain committed Jan 21, 2025
1 parent ef1f3ec commit 987169a
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions scripts/.local/bin/random/,gh-create-pr
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
#!/bin/sh

set -eo pipefail
set -euo pipefail

title="$(git log -1 --pretty=format:%s)"
body="$(git log -1 --pretty=format:%b)"
branches="$(git branch --sort=-committerdate | sed 's|^..||' | grep -v 'HEAD detached')"
head="$(echo "$branches" | fzf --prompt "Head branch: " --preview "git show {1}")"
base="$(echo "$branches" | grep -v "$head" | fzf --prompt "Base branch: " --preview "git show {1}")"

base="$(git branch --sort=-committerdate |
grep -v '\*' |
sed 's|^..||' |
fzf --header "Base branch" --height 40% --reverse --preview 'git log --oneline -20 {}')"

labels=""
printf "Add labels [y/N]: " && read -r add_labels
if [ "$add_labels" = "y" ]; then
labels="$(gh label list | {
printf '\n'
cat
} | fzf --header "Labels" -m | awk '{print $1}' | tr '\n' ',' | head -c-1)"
fi

cd "$(git rev-parse --show-toplevel 2>/dev/null)"

echo "$body" | cat - .github/pull_request_template.md >/tmp/pr_body
"${EDITOR:-vi}" /tmp/pr_body

url="$(gh pr create --title "$title" \
--body-file /tmp/pr_body --assignee meain \
--base "$base" --label "$labels")"

echo "$url"
open "$url"
gh pr create --base "$base" --head "$head" --web

0 comments on commit 987169a

Please sign in to comment.