kshutils/g

22 lines
690 B
Plaintext
Raw Permalink Normal View History

2023-06-28 11:54:52 +00:00
#!/usr/bin/env ksh
if [[ $1 = "pc" || ( $1 = "pr" && $2 = "create" ) ]]
then
2024-02-13 15:27:01 +00:00
remote=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null | cut -d/ -f1)
git push --set-upstream ${remote:-origin} $(git branch --show-current)
2023-06-28 11:54:52 +00:00
tmp=$(mktemp /tmp/g.XXXXXXXXXXX.md)
if [[ -f ~/.g.template ]]
then
lps=$(git show --pretty='format:%s' --no-patch | cut -d' ' -f1)
if [[ ! -z $lps ]]
then
2024-02-13 15:27:01 +00:00
url="https://liferay.atlassian.net/browse/"$lps
2023-06-28 11:54:52 +00:00
sed -e "s/{lps}/$lps/g" -e "s,{url},$url," <~/.g.template >$tmp
fi
fi
${GH_EDITOR:-${VISUAL:-${EDITOR:-ed}}} ${tmp} >/dev/null
gh $@ --title "$(head -1 $tmp)" --body "$(tail -n +3 $tmp)"
mv -f $tmp /tmp/g.lastpr
else
gh $@
fi