Skip to content

Commit

Permalink
use https_url in all commands
Browse files Browse the repository at this point in the history
  • Loading branch information
trxcllnt committed Jun 24, 2024
1 parent d02633e commit a049bec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
11 changes: 5 additions & 6 deletions features/src/utils/opt/devcontainer/bin/github/repo/clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ get_repo_owner() {

get_repo_git_url() {
local repo="${1}";
echo "$(
GH_HOST="${https_url}" gh repo view "${repo}" --json url --jq ".url").git";
echo "$(GH_HOST="${https_url}" gh repo view "${repo}" --json url --jq ".url").git";
}

get_repo_ssh_url() {
Expand Down Expand Up @@ -140,7 +139,7 @@ clone_github_repo() {
case "${CHOICE:-}" in
[Nn]* ) origin="${upstream}"; break;;
[Yy]* ) origin="${user}/${name}";
gh repo fork "${upstream}" --clone=false --default-branch-only;
GH_HOST="${https_url}" gh repo fork "${upstream}" --clone=false --default-branch-only;
break;;
* ) echo "Please answer 'y' or 'n'";;
esac
Expand All @@ -152,8 +151,8 @@ clone_github_repo() {

if test -z "${no_fork:-}" && \
test -z "${clone_upstream:-}" && \
gh auth status >/dev/null 2>&1; then
if [ "$(gh config get git_protocol)" = "ssh" ]; then
gh auth status --hostname "${https_url}" >/dev/null 2>&1; then
if [ "$(gh config get git_protocol --host "${https_url}")" = "ssh" ]; then
origin_="$(get_repo_ssh_url "${origin}")";
upstream_="$(get_repo_ssh_url "${upstream}")";
else
Expand All @@ -163,7 +162,7 @@ clone_github_repo() {
fi

if test -z "${origin_:-}" || test -z "${upstream_:-}"; then
if [ "$(gh config get git_protocol)" = "ssh" ]; then
if [ "$(gh config get git_protocol --host "${https_url}")" = "ssh" ]; then
origin_="${origin_:-"ssh://git@${ssh_url}/${origin}.git"}";
upstream_="${upstream_:-"ssh://git@${ssh_url}/${upstream}.git"}";
else
Expand Down
18 changes: 9 additions & 9 deletions features/src/utils/opt/devcontainer/bin/gitlab/repo/clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

get_default_branch() {
local repo="${1}";
glab api --hostname "${https_url}" graphql -f query="$(cat <<________EOF | tr -s '[:space:]'
glab api graphql --hostname "${https_url}" -f query="$(cat <<________EOF | tr -s '[:space:]'
query {
project(fullPath: "${repo}") {
repository {
Expand All @@ -42,7 +42,7 @@ ________EOF

get_repo_name() {
local repo="${1}";
glab api --hostname "${https_url}" graphql -f query="$(cat <<________EOF | tr -s '[:space:]'
glab api graphql --hostname "${https_url}" -f query="$(cat <<________EOF | tr -s '[:space:]'
query {
project(fullPath: "${repo}") {
path
Expand All @@ -55,7 +55,7 @@ ________EOF

get_repo_owner() {
local repo="${1}";
glab api --hostname "${https_url}" graphql -f query="$(cat <<________EOF | tr -s '[:space:]'
glab api graphql --hostname "${https_url}" -f query="$(cat <<________EOF | tr -s '[:space:]'
query {
project(fullPath: "${repo}") {
group {
Expand All @@ -70,7 +70,7 @@ ________EOF

get_repo_git_url() {
local repo="${1}";
glab api --hostname "${https_url}" graphql -f query="$(cat <<________EOF | tr -s '[:space:]'
glab api graphql --hostname "${https_url}" -f query="$(cat <<________EOF | tr -s '[:space:]'
query {
project(fullPath: "${repo}") {
httpUrlToRepo
Expand All @@ -84,7 +84,7 @@ ________EOF

get_repo_ssh_url() {
local repo="${1}";
glab api --hostname "${https_url}" graphql -f query="$(cat <<________EOF | tr -s '[:space:]'
glab api graphql --hostname "${https_url}" -f query="$(cat <<________EOF | tr -s '[:space:]'
query {
project(fullPath: "${repo}") {
sshUrlToRepo
Expand Down Expand Up @@ -163,7 +163,7 @@ clone_gitlab_repo() {
case "${CHOICE:-}" in
[Nn]* ) origin="${upstream}"; break;;
[Yy]* ) origin="${user}/${name}";
glab repo fork "${upstream}" --clone=false;
GL_HOST="${https_url}" glab repo fork "${upstream}" --clone=false;
break;;
* ) echo "Please answer 'y' or 'n'";;
esac
Expand All @@ -175,8 +175,8 @@ clone_gitlab_repo() {

if test -z "${no_fork:-}" && \
test -z "${clone_upstream:-}" && \
! glab auth status 2>&1 | grep -q "No token provided"; then
if [ "$(glab config get git_protocol)" = "ssh" ]; then
! glab auth status --hostname "${https_url}" 2>&1 | grep -q "No token provided"; then
if [ "$(glab config get git_protocol --host "${https_url}")" = "ssh" ]; then
origin_="$(get_repo_ssh_url "${origin}")";
upstream_="$(get_repo_ssh_url "${upstream}")";
else
Expand All @@ -186,7 +186,7 @@ clone_gitlab_repo() {
fi

if test -z "${origin_:-}" || test -z "${upstream_:-}"; then
if [ "$(glab config get git_protocol)" = "ssh" ]; then
if [ "$(glab config get git_protocol --host "${https_url}")" = "ssh" ]; then
origin_="${origin_:-"ssh://git@${ssh_url}/${origin}.git"}";
upstream_="${upstream_:-"ssh://git@${ssh_url}/${upstream}.git"}";
else
Expand Down

0 comments on commit a049bec

Please sign in to comment.