Skip to content

Instantly share code, notes, and snippets.

@tomi-font
Last active June 26, 2024 06:49
Show Gist options
  • Save tomi-font/e548c23c7d9a321d452dde9c4cc43fa4 to your computer and use it in GitHub Desktop.
Save tomi-font/e548c23c7d9a321d452dde9c4cc43fa4 to your computer and use it in GitHub Desktop.
Git hook to automatically run `west update` if the manifest file changed after a checkout/merge/rebase.
#!/usr/bin/env bash
#
# Based on: https://gist.github.com/foca/3148204
#
# Install into:
# - .git/hooks/post-checkout
# - .git/hooks/post-merge
# - .git/hooks/post-rewrite
# - .git/hooks/post-commit
#
# And make sure all are executable.
#
# Then change the $MANIFEST_FILE_PATH appropriately.
# The path starts from the root of the repository.
#
# Note that this covers the most common git operations
# but not all of them, so remain aware of the possibiltiy
# that your West workspace is left unupdated.
MANIFEST_FILE_PATH="west.yml"
if ! git diff --exit-code --quiet HEAD@{1}..HEAD@{0} "$MANIFEST_FILE_PATH"; then
west update
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment