From a888be6e0489ac8170a29f3deb60618e0d2420af Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Mon, 23 Jan 2023 23:05:53 +0000 Subject: [PATCH] Support both https/git by detection of origin root (#6651) * Support both https/git by detection of origin root * Remove unnecessary . * Minor comment fixup --- git-init.sh | 4 ++-- git-setup.sh | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/git-init.sh b/git-init.sh index 0fb7890985..045c134681 100755 --- a/git-init.sh +++ b/git-init.sh @@ -1,7 +1,7 @@ #!/bin/sh -# If there's a `.gitmodule` file skip this script +# Skip if `.gitmodules` exists [ -f .gitmodules ] && { - echo ".gitmodules already initializied" + echo ".gitmodules already initialized" exit 0 } diff --git a/git-setup.sh b/git-setup.sh index 0d1daac1f5..5f8b782058 100755 --- a/git-setup.sh +++ b/git-setup.sh @@ -5,11 +5,13 @@ if [ $# -eq 0 ]; then echo "Usage: git-setup.sh " exit 1 fi +# Get remote url to support either https or ssh +remote_url=$(echo $(git config --get remote.origin.url) | sed 's![^/]*$!!') # Loop through the requested modules for module in "$@"; do echo "Setting up '$module' module..." # Set the project git URL - project=$(echo "git@github.com:calcom/$module.git") + project=$remote_url$module.git # Check if we have access to the module if [ "$(git ls-remote "$project" 2>/dev/null)" ]; then echo "You have access to '${module}'" @@ -18,7 +20,7 @@ for module in "$@"; do # Prevents duplicate entries git config -f .gitmodules --unset-all "submodule.apps/$module.branch" # Add the submodule - git submodule add --force "git@github.com:calcom/$module.git" "apps/$module" + git submodule add --force $project "apps/$module" # Set the default branch to main git config -f .gitmodules --add "submodule.apps/$module.branch" main # Adding the subdmoule ignores the `.gitignore` so a reset is needed