fix: trim branch before uriencode

This commit is contained in:
2025-05-06 17:28:59 +03:00
parent b63987f83f
commit 8705353daf
2 changed files with 7 additions and 2 deletions

View File

@@ -17,6 +17,10 @@ uriencode() {
done
}
trim() {
echo "$1" | sed -E 's/^[ \t]+|[ \t]+$//g'
}
git_get_remote() {
remote=$(git remote -v | grep "(push)" | awk '{print $2}')
echo $remote
@@ -214,8 +218,8 @@ git_open_new_pr() {
default_branch="master"
fi
branch=$(uriencode $branch)
default_branch=$(uriencode $default_branch)
branch="$(uriencode $(trim $branch))"
default_branch="$(uriencode $(trim $default_branch))"
case "$remote_type" in
github) open_url "$silent" "https://github.com/$repo_path/compare/$default_branch...$branch" ;;

View File

@@ -79,6 +79,7 @@ describe "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)
assert_value "https://github.com/chenasraf/git-open/compare/develop...master" $(git_open_new_pr -f "master " " develop ")
describe "git_open_pipelines"
assert_value "https://github.com/chenasraf/git-open/actions" $(git_open_pipelines)