diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-02 09:39:04 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-02 09:39:04 +0200 |
commit | 706f2b0bd1e80a48899c28f75a0aa2ec51d2b93e (patch) | |
tree | ae3040ae6ac71599bbb5d2928377a5a6cd607da5 | |
parent | fe131f930ca6c560dea77fc3627f0f690c8c86e9 (diff) | |
download | obnam.org-706f2b0bd1e80a48899c28f75a0aa2ec51d2b93e.tar.gz |
add script to mirror from gitlab to my own server
-rwxr-xr-x | mirror.sh | 32 |
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 |