gitea-hooks/bin/clone-or-pull
Tony Tkacik cf772c9e40 Added basic status messages.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
2019-05-03 12:59:21 +02:00

27 lines
523 B
Bash
Executable file

#!/usr/bin/env bash
# FIXME: Add checks
# FIXME: Add logging
REPO="$PWD";
TARGET_DIR="$1";
BRANCH="$2";
function perform_clone_or_pull {
target="$1";
echo "Checking out working copy to remote:$target"
if [! -e "$target/.git" ]; then
git clone "$REPO" "$target";
fi
(
cd "$target";
git fetch
git checkout origin/$BRANCH
)
echo "Working copy checked out";
}
while read old_rew new_rew ref; do
if [ "$ref" == "refs/heads/$BRANCH" ]; then
perform_clone_or_pull "$TARGET_DIR";
fi;
done;