diff options
Diffstat (limited to 'templates/root_clone.sh')
| -rw-r--r-- | templates/root_clone.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/templates/root_clone.sh b/templates/root_clone.sh new file mode 100644 index 0000000..7f92c5f --- /dev/null +++ b/templates/root_clone.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +REPO="$1" +TARGET="$2" + +set -eux + +# Exits with 100 if the directory was changed + +if [ ! -d "$TARGET" ]; then + git clone --depth=1 --branch main --single-branch "$REPO" "$TARGET" + exit 100 +fi + +cd "$TARGET" +before=$(git rev-parse HEAD) +git fetch --depth=1 --prune origin main +git reset --hard origin/main +after=$(git rev-parse HEAD) + +if [ "$before" != "$after" ]; then exit 100; fi |
