@@ -152,6 +152,7 @@ main() {
152
152
153
153
# Determine installation options
154
154
if [ " $project_status " = " none" ] && [ " $global_status " = " none" ]; then
155
+ # Both are not installed - ask where to install
155
156
echo -e " \nWhere would you like to install GitGuard?"
156
157
echo -e " 1) Project only ${GREEN} [default]${NC} "
157
158
echo -e " 2) Global only"
@@ -175,26 +176,37 @@ main() {
175
176
;;
176
177
esac
177
178
else
178
- # Handle existing installations
179
- if [ " $project_status " = " gitguard" ] || [ " $global_status " = " gitguard" ]; then
180
- echo -e " \n${YELLOW} GitGuard is already installed. What would you like to do?${NC} "
181
- echo -e " 1) Reinstall existing hooks ${GREEN} [default]${NC} "
182
- echo -e " 2) Cancel"
183
- read -p " Select an option (1-2, press Enter to reinstall): " -r < /dev/tty
184
- echo
185
-
186
- # Default to option 1 (reinstall) if Enter is pressed
187
- REPLY=${REPLY:- 1}
188
-
189
- case $REPLY in
190
- 2) echo -e " ${YELLOW} Installation cancelled.${NC} " ;;
191
- * )
192
- # Directly reinstall without additional confirmation
193
- [ " $project_status " = " gitguard" ] && handle_installation " $( git rev-parse --git-dir) /hooks" " project"
194
- [ " $global_status " = " gitguard" ] && handle_installation " $GLOBAL_GIT_DIR " " global"
195
- ;;
196
- esac
179
+ # At least one is installed - show reinstall/install options
180
+ echo -e " \n${YELLOW} Installation options:${NC} "
181
+ if [ " $project_status " = " none" ]; then
182
+ echo -e " 1) Install project hooks"
183
+ else
184
+ echo -e " 1) Reinstall project hooks"
185
+ fi
186
+ if [ " $global_status " = " none" ]; then
187
+ echo -e " 2) Install global hooks"
188
+ else
189
+ echo -e " 2) Reinstall global hooks"
197
190
fi
191
+ echo -e " 3) Cancel ${GREEN} [default]${NC} "
192
+
193
+ read -p " Select an option (1-3, press Enter to cancel): " -r < /dev/tty
194
+ echo
195
+
196
+ case $REPLY in
197
+ 1)
198
+ if [ -n " $( git rev-parse --git-dir 2> /dev/null) " ]; then
199
+ handle_installation " $( git rev-parse --git-dir) /hooks" " project"
200
+ else
201
+ echo -e " ${RED} Not in a git repository${NC} "
202
+ fi
203
+ ;;
204
+ 2) handle_installation " $GLOBAL_GIT_DIR " " global" ;;
205
+ * )
206
+ echo -e " ${YELLOW} Installation cancelled.${NC} "
207
+ exit 0
208
+ ;;
209
+ esac
198
210
fi
199
211
}
200
212
@@ -216,6 +228,9 @@ handle_remote_install() {
216
228
# Set script directory to temp directory for installation
217
229
SCRIPT_DIR=" $temp_dir "
218
230
231
+ # Force interactive mode
232
+ export INTERACTIVE=1
233
+
219
234
# Run the main installation
220
235
main
221
236
}
0 commit comments