#!/bin/sh BARE_REPO_PATH="/home/mason/lakefox/remote/grim.git" WORKING_REPO_PATH="/home/mason/lakefox/grim2" LOG_FILE="/tmp/post-commit-grim-hook.log" log_message() { echo "$(date +'%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE" } log_message "--- Starting post-commit hook for $WORKING_REPO_PATH ---" if [ ! -d "$BARE_REPO_PATH" ]; then log_message "Bare repository not found at $BARE_REPO_PATH. Attempting to create it..." (cd "$(dirname "$WORKING_REPO_PATH")" && git clone --bare "$(basename "$WORKING_REPO_PATH")" "$BARE_REPO_PATH") >> "$LOG_FILE" 2>&1 if [ $? -ne 0 ]; then log_message "ERROR: Failed to create bare repository. Check previous errors." exit 1 fi log_message "Bare repository created successfully." fi log_message "Pushing changes from $WORKING_REPO_PATH to $BARE_REPO_PATH..." git push --mirror "$BARE_REPO_PATH" >> "$LOG_FILE" 2>&1 if [ $? -ne 0 ]; then log_message "ERROR: git push --mirror failed. Check previous errors." exit 1 fi # --- NEW: Update server info in the bare repository --- log_message "Updating server info in bare repository ($BARE_REPO_PATH)..." # Go into the bare repository directory to run the command (cd "$BARE_REPO_PATH" && git update-server-info) >> "$LOG_FILE" 2>&1 if [ $? -ne 0 ]; then log_message "ERROR: git update-server-info failed in bare repository." exit 1 fi log_message "Server info updated successfully." # --- END NEW --- log_message "Bare repo updated successfully." log_message "--- Post-commit hook finished ---"