Skip to content

Commit df3a048

Browse files
Added the git init
Signed-off-by: The-Repo-Club <wayne6324@gmail.com>
1 parent 0f525cf commit df3a048

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

proctl

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# GitHub - https://github.com/The-Repo-Club/
66
# Author - The-Repo-Club [wayne6324@gmail.com]
77
# Start On - Fri 18 February 2022, 07:26:28 pm (GMT)
8-
# Modified On - Sun 20 February 2022, 01:13:49 pm (GMT)
8+
# Modified On - Mon 21 February 2022, 04:13:30 pm (GMT)
99
# -------------------------------------------------------------------------
1010
#
1111
#
@@ -130,6 +130,44 @@ make_new_config() {
130130
#==============================================================================
131131
}
132132

133+
#=== FUNCTION =================================================================
134+
# Name: initialize_repo
135+
# Description: initialize a git repo
136+
#==============================================================================
137+
138+
initialize_repo() {
139+
depend 'git'
140+
isGit=$(git -C . rev-parse 2>/dev/null; echo $?)
141+
if [[ "$isGit" -eq "0" ]]; then
142+
printf ' Do you want to reinitialize this git repo? [y/N] '
143+
read -r yn
144+
[[ ! "$yn" = "y" ]] && exit
145+
git init
146+
arrIN=(${@//\// })
147+
if [[ "${arrIN[0]}" == "ssh" ]]; then
148+
AUTHOR_GIT_SSH=${AUTHOR_GIT/http[s]:\/\//git@}
149+
remote="$AUTHOR_GIT_SSH${arrIN[1]}.git"
150+
git remote add origin "${remote}"
151+
else
152+
remote="$AUTHOR_GIT${1}.git"
153+
git remote add origin "${remote}"
154+
fi
155+
return
156+
else
157+
git init
158+
arrIN=(${@//\// })
159+
if [[ "${arrIN[0]}" == "ssh" ]]; then
160+
AUTHOR_GIT_SSH=${AUTHOR_GIT/http[s]:\/\//git@}
161+
remote="$AUTHOR_GIT_SSH${arrIN[1]}.git"
162+
remote add origin "${remote}"
163+
else
164+
remote="$AUTHOR_GIT${1}.git"
165+
remote add origin "${remote}"
166+
fi
167+
return
168+
fi
169+
}
170+
133171
#=== FUNCTION =================================================================
134172
# Name: check_valid_license
135173
# Description: check if valid license
@@ -583,7 +621,7 @@ main() {
583621
check_license_conflict
584622
case "$1" in
585623
-help | -h) usage ;;
586-
-initialize | -i) initialize_repo ;;
624+
-initialize | -i) initialize_repo "$2";;
587625
-list-licenses | -l) list_licenses ;;
588626
-list-languages | -ll) list_languages ;;
589627
-current-license | -c) einfo "$(show_license)" ;;

0 commit comments

Comments
 (0)