Skip to content

Commit

Permalink
Improve post-checkout hook
Browse files Browse the repository at this point in the history
This now also initializes a new submodule.
  • Loading branch information
fphilipe committed Feb 15, 2023
1 parent b64fad5 commit f3bcbe3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions git_template/hooks/post-checkout
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/env bash

git config --file .gitmodules --get-regexp path \
| awk '{print $2}' \
| while read -r submodule; do
diff="$(git diff -- "$submodule")"
if [[ "$diff" = *-dirty ]]; then
git submodule status \
| while read -r sha submodule rest; do
if [[ "$(git diff -- "$submodule")" = *-dirty ]]; then
echo "Submodule path '$submodule': dirty, not updating"
elif [[ -n "$diff" ]]; then
elif [[ "$sha" = [-+]* ]]; then
git submodule update --init -- "$submodule"
fi
done

0 comments on commit f3bcbe3

Please sign in to comment.