diff options
author | NP-Hardass <NP-Hardass@gentoo.org> | 2016-09-20 17:04:47 -0400 |
---|---|---|
committer | NP-Hardass <NP-Hardass@gentoo.org> | 2016-09-20 17:06:12 -0400 |
commit | c34323cac9e58597528c2e754fe3b45fe53ccae7 (patch) | |
tree | dd4e8bd39e4923da78b6e89c10ed584c4caf8dae /scripts | |
parent | mate-extra/mate-media: Bump to 1.14.1 (diff) | |
download | gentoo-mate-c34323cac9e58597528c2e754fe3b45fe53ccae7.tar.gz gentoo-mate-c34323cac9e58597528c2e754fe3b45fe53ccae7.tar.bz2 gentoo-mate-c34323cac9e58597528c2e754fe3b45fe53ccae7.zip |
scripts: Add script to initialize hooks and remotes for mirror
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/hooks/post-receive | 3 | ||||
-rwxr-xr-x | scripts/init-repo-mirror | 51 |
2 files changed, 54 insertions, 0 deletions
diff --git a/scripts/hooks/post-receive b/scripts/hooks/post-receive new file mode 100755 index 0000000..0ca209b --- /dev/null +++ b/scripts/hooks/post-receive @@ -0,0 +1,3 @@ +#!/bin/sh + +nohup git push github &>/dev/null & diff --git a/scripts/init-repo-mirror b/scripts/init-repo-mirror new file mode 100755 index 0000000..d2910d9 --- /dev/null +++ b/scripts/init-repo-mirror @@ -0,0 +1,51 @@ +#!/bin/sh + +die(){ + echo "$@" + exit 1 +} + +help_info(){ + echo "Initialize repository to allow mirroring." + echo "--hooks: installs git hooks for syncronization" + echo "--remotes: configures github remotes" + echo "--help/-h: display this message" + exit 0 +} + +[[ -d .git/ ]] || die "Must be run from repository root!" + +if [[ $# -eq 0 ]]; then + eval set -- "--hooks --remotes" +fi + +OPTS=`getopt -o h --long hooks,remotes,help -n 'parse-options' -- "$@"` + +if [[ $? -ne 0 ]]; then + die "Invalid arguments" +fi + +eval set -- "${OPTS}" + +HOOKS=false +REMOTES=false + +while true; do + case "$1" in + --hooks ) HOOKS=true; shift ;; + --remotes ) REMOTES=true; shift ;; + --help | -h ) help-info ;; + -- ) shift; break;; + * ) break ;; + esac +done + +if ${HOOKS}; then + echo "Installing Repository Hooks" + cp scripts/hooks/post-receive .git/hooks/post-receive || die "Failed to install hooks" +fi + +if ${REMOTES}; then + echo "Configuring Remotes" + git add remote github https://github.com/gentoo/gentoo-mate/ || die "Failed to configure remotes" +fi |