diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-02 07:39:55 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-02 07:39:55 +0000 |
commit | 7831bcebaa78ec11724e74b0a61e0bba51fcf678 (patch) | |
tree | ae3040ae6ac71599bbb5d2928377a5a6cd607da5 | |
parent | fe131f930ca6c560dea77fc3627f0f690c8c86e9 (diff) | |
parent | 706f2b0bd1e80a48899c28f75a0aa2ec51d2b93e (diff) | |
download | obnam.org-7831bcebaa78ec11724e74b0a61e0bba51fcf678.tar.gz |
Merge branch 'mirror' into 'master'
add script to mirror from gitlab to my own server
See merge request larswirzenius/obnam.org!1
-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 |