mkrep can now pick a git host from --server, $GIT_SERVER, and $GITEA_URL/$GITEA_HOST/$GITLAB_URL/$GITLAB_HOST (base URL only -- type must come from --server/$GIT_SERVER, so setting those URL vars for an unrelated tool can't silently turn a plain mkrep call into a remote-creating one). Before creating anything it checks via gh/glab/tea whether the repo already exists and links instead of recreating it; --check-existing runs just that check and reports without touching remotes.
37 lines
1.1 KiB
Fish
37 lines
1.1 KiB
Fish
# Copyright (C) 2026 Rootiest
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
# SYNOPSIS
|
|
# _mkrep_remote_url <type> <user> <name> <url>
|
|
#
|
|
# DESCRIPTION
|
|
# Builds the clone URL for a repo on <type>, for mkrep's --server flow:
|
|
# linking to a repo that already exists, and reporting the URL of one it
|
|
# just created. <url> is the resolved server base (from --server/$GIT_SERVER
|
|
# plus $GITEA_URL/$GITEA_HOST/$GITLAB_URL/$GITLAB_HOST) and is unused for
|
|
# github, which always resolves to github.com.
|
|
#
|
|
# ARGUMENTS
|
|
# type gitea, gitlab, or github
|
|
# user Account/namespace the repo lives under
|
|
# name Repo name
|
|
# url Server base URL (required for gitea/gitlab)
|
|
#
|
|
# RETURNS
|
|
# The clone URL, on stdout
|
|
#
|
|
# EXIT STATUS
|
|
# 0 URL built
|
|
# 1 unrecognized type, or gitea/gitlab given with no url
|
|
function _mkrep_remote_url --argument-names type user name url
|
|
switch $type
|
|
case github
|
|
echo "https://github.com/$user/$name.git"
|
|
case gitlab gitea
|
|
test -n "$url"; or return 1
|
|
echo "$url/$user/$name.git"
|
|
case '*'
|
|
return 1
|
|
end
|
|
end
|