summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmirror.sh32
1 files changed, 32 insertions, 0 deletions
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