Skip to content

Commit 4efb752

Browse files
Download the post-checkout git hook to ~/.luca in install.sh
1 parent 86e1f28 commit 4efb752

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

install.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ REPOSITORY_URL="https://github.com/LucaTools/Luca"
1818
TOOL_DIR="$HOME/$TOOL_FOLDER"
1919
SHELL_HOOK_SCRIPT_PATH="$TOOL_DIR/shell_hook.sh"
2020
SHELL_HOOK_SCRIPT_URL="https://raw.githubusercontent.com/LucaTools/LucaScripts/HEAD/shell_hook.sh"
21+
POST_CHECKOUT_HOOK_PATH="$TOOL_DIR/post-checkout"
2122
POST_CHECKOUT_HOOK_URL="https://raw.githubusercontent.com/LucaTools/LucaScripts/HEAD/post-checkout"
2223

2324
# =============================================================================
@@ -253,6 +254,18 @@ else
253254
fi
254255
fi
255256

257+
# Download the post-checkout hook script to ~/.luca/ for later use
258+
echo "📥 Downloading post-checkout hook script..."
259+
curl -LSsf --output "$POST_CHECKOUT_HOOK_PATH" "$POST_CHECKOUT_HOOK_URL"
260+
261+
POST_CHECKOUT_DOWNLOAD_SUCCESS=$?
262+
if [ $POST_CHECKOUT_DOWNLOAD_SUCCESS -ne 0 ]; then
263+
echo "⚠️ WARNING: Could not download post-checkout hook from $POST_CHECKOUT_HOOK_URL"
264+
else
265+
echo "✅ Post-checkout hook downloaded to $POST_CHECKOUT_HOOK_PATH"
266+
chmod +x "$POST_CHECKOUT_HOOK_PATH"
267+
fi
268+
256269
# =============================================================================
257270
# GIT POST-CHECKOUT HOOK SETUP (OPTIONAL)
258271
# =============================================================================
@@ -291,21 +304,21 @@ install_git_hook() {
291304
else
292305
echo "⚠️ A post-checkout hook already exists at $hook_file"
293306
echo " To install Luca's hook, please manually merge or replace it."
294-
echo " The hook script content can be found at:"
295-
echo " $POST_CHECKOUT_HOOK_URL"
307+
echo " The hook script can be found at: $POST_CHECKOUT_HOOK_PATH"
296308
return 0
297309
fi
298310
fi
299311

300-
# Download and install the hook
312+
# Copy from local ~/.luca/post-checkout (already downloaded earlier)
301313
echo "📥 Installing git post-checkout hook..."
302-
if curl -LSsf --output "$hook_file" "$POST_CHECKOUT_HOOK_URL"; then
314+
if [ -f "$POST_CHECKOUT_HOOK_PATH" ]; then
315+
cp "$POST_CHECKOUT_HOOK_PATH" "$hook_file"
303316
chmod +x "$hook_file"
304317
echo "✅ Git post-checkout hook installed at $hook_file"
305318
GIT_HOOK_INSTALLED=true
306319
GIT_HOOK_PATH="$hook_file"
307320
else
308-
echo "⚠️ Could not download post-checkout hook (non-fatal)"
321+
echo "⚠️ Could not install post-checkout hook (source not found)"
309322
fi
310323
}
311324

@@ -324,7 +337,7 @@ echo " • Executable: $EXECUTABLE_FILE"
324337
echo " • Version: $REQUIRED_EXECUTABLE_VERSION"
325338
echo " • Shell Hook: $SHELL_HOOK_SCRIPT_PATH"
326339
if [ "$GIT_HOOK_INSTALLED" = "true" ]; then
327-
echo "Git Hook: $GIT_HOOK_PATH"
340+
echo "Post-checkout Hook: $POST_CHECKOUT_HOOK_PATH"
328341
fi
329342
echo ""
330343
echo "💡 To start using Luca:"

0 commit comments

Comments
 (0)