Scripts for syncing the state of the vendor forlder with the workspace

This commit is contained in:
Zahary Karadjov 2022-07-04 14:37:58 +03:00
parent 325e03f419
commit 2519e69fc8
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
3 changed files with 58 additions and 0 deletions

14
scripts/lib/git-helpers Normal file
View File

@ -0,0 +1,14 @@
function copy_revision {
if [ -d "$1" ] && [ -d "$2" ]; then
pushd "$1" > /dev/null
COMMIT="$(git rev-parse HEAD)"
echo Switching "$(basename "$2")" to $COMMIT
popd > /dev/null
pushd "$2"
git checkout "$COMMIT"
popd > /dev/null
else
echo "Usage: copy_revision <git-dir-1> <git-dir-2>"
fi
}

View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
shopt -s nocaseglob
GIR_PROJECT_DIR=$(git rev-parse --show-toplevel)
cd "$GIT_PROJECT_DIR"
if [ ! -d vendor ]; then
SCRIPT_NAME=$(basename "$0")
echo "${SCRIPT_NAME} must be executed within a git repo, holding a 'vendor' folder"
exit 1
fi
source ../scripts/lib/git-helpers
for submodule in vendor/*/; do
WORKSPACE_DIR="../$(basename "$submodule")"
if [ -d "$WORKSPACE_DIR" ]; then
copy_revision "$WORKSPACE_DIR" "$submodule"
fi
done

View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
shopt -s nocaseglob
GIR_PROJECT_DIR=$(git rev-parse --show-toplevel)
cd "$GIT_PROJECT_DIR"
if [ ! -d vendor ]; then
SCRIPT_NAME=$(basename "$0")
echo "${SCRIPT_NAME} must be executed within a git repo, holding a 'vendor' folder"
exit 1
fi
source ../scripts/lib/git-helpers
for submodule in vendor/*/; do
WORKSPACE_DIR="../$(basename "$submodule")"
if [ -d "$WORKSPACE_DIR" ]; then
copy_revision "$submodule" "$WORKSPACE_DIR"
fi
done