Skip to content

Commit

Permalink
Merge branch 'v2' of https://github.com/maxheld83/muggle into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
maxheld83 committed Jan 20, 2025
2 parents 826bf80 + 53ec19b commit 746cf91
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ devops package
Run this once to set up the git hooks.

```sh
cp -f muggle/post-checkout.sample .git/modules/muggle/hooks/post-checkout
cp -f muggle/update_hook.sample .git/modules/muggle/hooks/post-checkout
chmod +x .git/modules/muggle/hooks/post-checkout
cp -f muggle/post-checkout.sample .git/modules/muggle/hooks/post-merge
cp -f muggle/update_hook.sample .git/modules/muggle/hooks/post-merge
chmod +x .git/modules/muggle/hooks/post-merge
cp -f muggle/post-checkout.sample .git/modules/muggle/hooks/post-rewrite
cp -f muggle/update_hook.sample .git/modules/muggle/hooks/post-rewrite
chmod +x .git/modules/muggle/hooks/post-rewrite
sh muggle/install.sh
```
Expand Down
24 changes: 0 additions & 24 deletions post-checkout.sample

This file was deleted.

21 changes: 21 additions & 0 deletions update_hook.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Check if we are in a submodule
if git rev-parse --show-superproject-working-tree > /dev/null 2>&1; then
# We're in a submodule. Get the submodule's working directory
SUBMODULE_ROOT="$(git rev-parse --show-toplevel)"
else
# We're in a normal repo
SUBMODULE_ROOT="$(pwd)"
fi

# Path to install.sh relative to the repo/submodule root
INSTALL_SCRIPT="$SUBMODULE_ROOT/install.sh"

# Check if install.sh exists and is executable
if [ -x "$INSTALL_SCRIPT" ]; then
# Run the install script with the arguments passed to the hook
"$INSTALL_SCRIPT" "$@"
else
echo "Warning: install.sh not found or not executable at $INSTALL_SCRIPT" >&2
fi

0 comments on commit 746cf91

Please sign in to comment.