From 0a14bff80ca5e5bf69236b9fa4909e7059326841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Sun, 30 Oct 2022 00:51:35 +0200 Subject: [PATCH] ansible/gitpull.sh: add script for updating repos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- ansible/gitpull.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 ansible/gitpull.sh diff --git a/ansible/gitpull.sh b/ansible/gitpull.sh new file mode 100755 index 0000000..ef801a1 --- /dev/null +++ b/ansible/gitpull.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e + +for DIR in ~/work/infra-*; do + pushd $DIR >/dev/null + NAME=$(basename $DIR) + BRANCH=$(git rev-parse --abbrev-ref HEAD) + if [[ "${BRANCH}" != "master" ]]; then + printf "%-30s - %s\n" "$NAME" "FEATURE" + elif git diff --quiet; then + git pull origin master >/dev/null 2>&1 + printf "%-30s - %s\n" "$NAME" "UPDATED" + else + printf "%-30s - %s\n" "$NAME" "DIRTY" + git status + fi + popd >/dev/null +done