fix: github find pr

This commit is contained in:
2024-08-21 15:04:44 +03:00
committed by Chen Asraf
parent ac3b39f063
commit 04e7e69475
2 changed files with 10 additions and 6 deletions

View File

@@ -183,10 +183,14 @@ git_open_pr_list() {
}
git_open_new_pr() {
existing="$(git_find_pr $@)"
if [[ "$1" == "--force" || "$1" == "-f" ]]; then
shift
existing=""
else
existing="$(git_find_pr $@)"
fi
if [[ -n "$existing" ]]; then
echo "PR already exists: $existing"
open_url "$silent" $existing
return 0
fi
@@ -240,7 +244,7 @@ git_find_pr() {
commit="$(git rev-parse $branch)"
case "$remote_type" in
github) prrefs="pulls/*/head"; prfilt="pulls" ;;
github) prrefs="pull/*/head"; prfilt="pull" ;;
gitlab) prrefs="merge-requests/*/head"; prfilt="merge-requests" ;;
bitbucket) prrefs="pull-requests/*/head"; prfilt="pull-requests" ;;
esac

View File

@@ -76,9 +76,9 @@ describe "git_open_pr_list"
assert_value "https://github.com/chenasraf/git-open/pulls?q=is%3Apr+is%3Aopen" $(git_open_pr_list)
describe "git_open_new_pr"
assert_value "https://github.com/chenasraf/git-open/compare/develop...master" $(git_open_new_pr master develop)
assert_value "https://github.com/chenasraf/git-open/compare/master...develop" $(git_open_new_pr develop)
assert_value "https://github.com/chenasraf/git-open/compare/master...$current_branch" $(git_open_new_pr)
assert_value "https://github.com/chenasraf/git-open/compare/develop...master" $(git_open_new_pr -f master develop)
assert_value "https://github.com/chenasraf/git-open/compare/master...develop" $(git_open_new_pr -f develop)
assert_value "https://github.com/chenasraf/git-open/compare/master...$current_branch" $(git_open_new_pr -f)
describe "git_open_pipelines"
assert_value "https://github.com/chenasraf/git-open/actions" $(git_open_pipelines)