@@ -18,6 +18,7 @@ REPOSITORY_URL="https://github.com/LucaTools/Luca"
1818TOOL_DIR=" $HOME /$TOOL_FOLDER "
1919SHELL_HOOK_SCRIPT_PATH=" $TOOL_DIR /shell_hook.sh"
2020SHELL_HOOK_SCRIPT_URL=" https://raw.githubusercontent.com/LucaTools/LucaScripts/HEAD/shell_hook.sh"
21+ POST_CHECKOUT_HOOK_URL=" https://raw.githubusercontent.com/LucaTools/LucaScripts/HEAD/post-checkout"
2122
2223# =============================================================================
2324# TOOL VERSION DETECTION
@@ -252,6 +253,65 @@ else
252253 fi
253254fi
254255
256+ # =============================================================================
257+ # GIT POST-CHECKOUT HOOK SETUP (OPTIONAL)
258+ # =============================================================================
259+
260+ # Track whether git hook was installed (used in summary)
261+ GIT_HOOK_INSTALLED=false
262+ GIT_HOOK_PATH=" "
263+
264+ # Install git hook if we're in a git repository
265+ install_git_hook () {
266+ local git_root
267+ git_root=$( git rev-parse --show-toplevel 2> /dev/null)
268+
269+ if [ -z " $git_root " ]; then
270+ # Not in a git repository, skip
271+ return 0
272+ fi
273+
274+ local hooks_dir=" $git_root /.git/hooks"
275+ local hook_file=" $hooks_dir /post-checkout"
276+
277+ # Check if hooks directory exists
278+ if [ ! -d " $hooks_dir " ]; then
279+ echo " ⚠️ Git hooks directory not found, skipping git hook installation"
280+ return 0
281+ fi
282+
283+ # Check if hook already exists
284+ if [ -f " $hook_file " ]; then
285+ # Check if it's our hook by looking for the Luca identifier
286+ if grep -q " LUCA POST-CHECKOUT GIT HOOK" " $hook_file " 2> /dev/null; then
287+ echo " ℹ️ Luca post-checkout hook already installed"
288+ GIT_HOOK_INSTALLED=true
289+ GIT_HOOK_PATH=" $hook_file "
290+ return 0
291+ else
292+ echo " ⚠️ A post-checkout hook already exists at $hook_file "
293+ 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 "
296+ return 0
297+ fi
298+ fi
299+
300+ # Download and install the hook
301+ echo " 📥 Installing git post-checkout hook..."
302+ if curl -LSsf --output " $hook_file " " $POST_CHECKOUT_HOOK_URL " ; then
303+ chmod +x " $hook_file "
304+ echo " ✅ Git post-checkout hook installed at $hook_file "
305+ GIT_HOOK_INSTALLED=true
306+ GIT_HOOK_PATH=" $hook_file "
307+ else
308+ echo " ⚠️ Could not download post-checkout hook (non-fatal)"
309+ fi
310+ }
311+
312+ # Try to install the git hook (optional, won't fail installation if it fails)
313+ install_git_hook
314+
255315# =============================================================================
256316# INSTALLATION COMPLETE
257317# =============================================================================
@@ -263,6 +323,9 @@ echo "📋 Installation Summary:"
263323echo " • Executable: $EXECUTABLE_FILE "
264324echo " • Version: $REQUIRED_EXECUTABLE_VERSION "
265325echo " • Shell Hook: $SHELL_HOOK_SCRIPT_PATH "
326+ if [ " $GIT_HOOK_INSTALLED " = " true" ]; then
327+ echo " • Git Hook: $GIT_HOOK_PATH "
328+ fi
266329echo " "
267330echo " 💡 To start using Luca:"
268331
0 commit comments