Skip to content

Commit 04e7e69

Browse files
committed
fix: github find pr
1 parent ac3b39f commit 04e7e69

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

git-open.zsh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,14 @@ git_open_pr_list() {
183183
}
184184

185185
git_open_new_pr() {
186-
existing="$(git_find_pr $@)"
186+
if [[ "$1" == "--force" || "$1" == "-f" ]]; then
187+
shift
188+
existing=""
189+
else
190+
existing="$(git_find_pr $@)"
191+
fi
187192

188193
if [[ -n "$existing" ]]; then
189-
echo "PR already exists: $existing"
190194
open_url "$silent" $existing
191195
return 0
192196
fi
@@ -240,7 +244,7 @@ git_find_pr() {
240244
commit="$(git rev-parse $branch)"
241245

242246
case "$remote_type" in
243-
github) prrefs="pulls/*/head"; prfilt="pulls" ;;
247+
github) prrefs="pull/*/head"; prfilt="pull" ;;
244248
gitlab) prrefs="merge-requests/*/head"; prfilt="merge-requests" ;;
245249
bitbucket) prrefs="pull-requests/*/head"; prfilt="pull-requests" ;;
246250
esac

tests/test.zsh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ describe "git_open_pr_list"
7676
assert_value "https://github.com/chenasraf/git-open/pulls?q=is%3Apr+is%3Aopen" $(git_open_pr_list)
7777

7878
describe "git_open_new_pr"
79-
assert_value "https://github.com/chenasraf/git-open/compare/develop...master" $(git_open_new_pr master develop)
80-
assert_value "https://github.com/chenasraf/git-open/compare/master...develop" $(git_open_new_pr develop)
81-
assert_value "https://github.com/chenasraf/git-open/compare/master...$current_branch" $(git_open_new_pr)
79+
assert_value "https://github.com/chenasraf/git-open/compare/develop...master" $(git_open_new_pr -f master develop)
80+
assert_value "https://github.com/chenasraf/git-open/compare/master...develop" $(git_open_new_pr -f develop)
81+
assert_value "https://github.com/chenasraf/git-open/compare/master...$current_branch" $(git_open_new_pr -f)
8282

8383
describe "git_open_pipelines"
8484
assert_value "https://github.com/chenasraf/git-open/actions" $(git_open_pipelines)

0 commit comments

Comments
 (0)