From df3a0487f8129043d84e1b1ec0abfc4bbbe1839e Mon Sep 17 00:00:00 2001 From: The-Repo-Club Date: Mon, 21 Feb 2022 16:13:41 +0000 Subject: [PATCH] Added the git init Signed-off-by: The-Repo-Club --- proctl | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/proctl b/proctl index 7b62d0d..a27da42 100755 --- a/proctl +++ b/proctl @@ -5,7 +5,7 @@ # GitHub - https://github.com/The-Repo-Club/ # Author - The-Repo-Club [wayne6324@gmail.com] # Start On - Fri 18 February 2022, 07:26:28 pm (GMT) -# Modified On - Sun 20 February 2022, 01:13:49 pm (GMT) +# Modified On - Mon 21 February 2022, 04:13:30 pm (GMT) # ------------------------------------------------------------------------- # # @@ -130,6 +130,44 @@ make_new_config() { #============================================================================== } +#=== FUNCTION ================================================================= +# Name: initialize_repo +# Description: initialize a git repo +#============================================================================== + +initialize_repo() { + depend 'git' + isGit=$(git -C . rev-parse 2>/dev/null; echo $?) + if [[ "$isGit" -eq "0" ]]; then + printf ' Do you want to reinitialize this git repo? [y/N] ' + read -r yn + [[ ! "$yn" = "y" ]] && exit + git init + arrIN=(${@//\// }) + if [[ "${arrIN[0]}" == "ssh" ]]; then + AUTHOR_GIT_SSH=${AUTHOR_GIT/http[s]:\/\//git@} + remote="$AUTHOR_GIT_SSH${arrIN[1]}.git" + git remote add origin "${remote}" + else + remote="$AUTHOR_GIT${1}.git" + git remote add origin "${remote}" + fi + return + else + git init + arrIN=(${@//\// }) + if [[ "${arrIN[0]}" == "ssh" ]]; then + AUTHOR_GIT_SSH=${AUTHOR_GIT/http[s]:\/\//git@} + remote="$AUTHOR_GIT_SSH${arrIN[1]}.git" + remote add origin "${remote}" + else + remote="$AUTHOR_GIT${1}.git" + remote add origin "${remote}" + fi + return + fi +} + #=== FUNCTION ================================================================= # Name: check_valid_license # Description: check if valid license @@ -583,7 +621,7 @@ main() { check_license_conflict case "$1" in -help | -h) usage ;; - -initialize | -i) initialize_repo ;; + -initialize | -i) initialize_repo "$2";; -list-licenses | -l) list_licenses ;; -list-languages | -ll) list_languages ;; -current-license | -c) einfo "$(show_license)" ;;