|
5 | 5 | # GitHub - https://github.com/The-Repo-Club/ |
6 | 6 | # Author - The-Repo-Club [wayne6324@gmail.com] |
7 | 7 | # 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) |
9 | 9 | # ------------------------------------------------------------------------- |
10 | 10 | # |
11 | 11 | # |
@@ -130,6 +130,44 @@ make_new_config() { |
130 | 130 | #============================================================================== |
131 | 131 | } |
132 | 132 |
|
| 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 | + |
133 | 171 | #=== FUNCTION ================================================================= |
134 | 172 | # Name: check_valid_license |
135 | 173 | # Description: check if valid license |
@@ -583,7 +621,7 @@ main() { |
583 | 621 | check_license_conflict |
584 | 622 | case "$1" in |
585 | 623 | -help | -h) usage ;; |
586 | | - -initialize | -i) initialize_repo ;; |
| 624 | + -initialize | -i) initialize_repo "$2";; |
587 | 625 | -list-licenses | -l) list_licenses ;; |
588 | 626 | -list-languages | -ll) list_languages ;; |
589 | 627 | -current-license | -c) einfo "$(show_license)" ;; |
|
0 commit comments