From 706f2b0bd1e80a48899c28f75a0aa2ec51d2b93e Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 2 Nov 2020 09:39:04 +0200 Subject: add script to mirror from gitlab to my own server --- mirror.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 mirror.sh diff --git a/mirror.sh b/mirror.sh new file mode 100755 index 0000000..e9a808a --- /dev/null +++ b/mirror.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -euo pipefail + +die() +{ + echo "$@" 1>&2 + exit 1 +} + +current_branch() +{ + git rev-parse --abbrev-ref HEAD +} + +uncommitted () { + git status --short | grep '^ M ' > /dev/null +} + +case "$(current_branch)" in + master|main) + if uncommitted + then + die "there are uncommitted change" + fi + git pull --rebase gitlab HEAD + git push origin HEAD + ;; + *) + die "not in main or master branch" + ;; +esac -- cgit v1.2.1