fix(git): prepend https:// to *_HOST vars in mkrep server detection
$GITEA_HOST/$GITLAB_HOST are bare hostnames (git.example.com); only $GITEA_URL/$GITLAB_URL are expected to carry a scheme. mkrep was using _HOST values as-is, producing a schemeless clone URL when only the _HOST var was set.
This commit is contained in:
@@ -42,7 +42,9 @@
|
||||
# --server <type> (gitea, gitlab, or github) picks a host without an
|
||||
# explicit --remote/--new-remote: resolve its base URL from
|
||||
# $GITEA_URL/$GITEA_HOST (gitea) or $GITLAB_URL/$GITLAB_HOST (gitlab),
|
||||
# preferring the _URL form when both are set, then run
|
||||
# preferring the _URL form when both are set. _URL is used as-is and
|
||||
# must include its scheme (https://git.example.com); _HOST is bare
|
||||
# (git.example.com) and gets https:// prepended. Then run
|
||||
# $MKREP_REMOTE_CMD or that type's built-in default template. With no
|
||||
# --server, --remote, or --new-remote, $GIT_SERVER picks the type the
|
||||
# same way (invalid values are rejected the same as an invalid
|
||||
@@ -195,13 +197,13 @@ function mkrep --description 'Create a directory, cd into it, and git init it'
|
||||
if test -n "$GITEA_URL"
|
||||
set srv_url $GITEA_URL
|
||||
else if test -n "$GITEA_HOST"
|
||||
set srv_url $GITEA_HOST
|
||||
set srv_url "https://$GITEA_HOST"
|
||||
end
|
||||
case gitlab
|
||||
if test -n "$GITLAB_URL"
|
||||
set srv_url $GITLAB_URL
|
||||
else if test -n "$GITLAB_HOST"
|
||||
set srv_url $GITLAB_HOST
|
||||
set srv_url "https://$GITLAB_HOST"
|
||||
end
|
||||
case github
|
||||
# gh defaults to github.com; no base url needed
|
||||
|
||||
@@ -289,6 +289,38 @@ begin
|
||||
rm -rf $base
|
||||
end
|
||||
|
||||
section "mkrep: \$GITEA_HOST gets https:// prepended, \$GITEA_URL wins over it"
|
||||
|
||||
begin
|
||||
_mkrep_stub_tool tea 1
|
||||
set -l base (_mkrep_sandbox)
|
||||
set -l target $base/repo
|
||||
set -lx PATH $stub_bin $PATH
|
||||
set -lx GITEA_URL ''
|
||||
set -lx GITEA_HOST gitea.example.invalid
|
||||
set -lx MKREP_REMOTE_CMD 'echo {server} >created.txt'
|
||||
mkrep --server gitea $target >/dev/null
|
||||
check "bare \$GITEA_HOST exits 0" 0 $status
|
||||
check "bare \$GITEA_HOST gets https:// prepended" https://gitea.example.invalid (cat $target/created.txt)
|
||||
cd $start
|
||||
rm -rf $base
|
||||
end
|
||||
|
||||
begin
|
||||
_mkrep_stub_tool tea 1
|
||||
set -l base (_mkrep_sandbox)
|
||||
set -l target $base/repo
|
||||
set -lx PATH $stub_bin $PATH
|
||||
set -lx GITEA_HOST wrong.example.invalid
|
||||
set -lx GITEA_URL https://right.example.invalid
|
||||
set -lx MKREP_REMOTE_CMD 'echo {server} >created.txt'
|
||||
mkrep --server gitea $target >/dev/null
|
||||
check "\$GITEA_URL wins over \$GITEA_HOST exits 0" 0 $status
|
||||
check "\$GITEA_URL wins over \$GITEA_HOST, used as-is" https://right.example.invalid (cat $target/created.txt)
|
||||
cd $start
|
||||
rm -rf $base
|
||||
end
|
||||
|
||||
section "mkrep: \$GITEA_URL alone (no \$GIT_SERVER) does not trigger anything"
|
||||
|
||||
begin
|
||||
|
||||
Reference in New Issue
Block a user