From 202690620b70bcf893e0bef2d5521e15c6f2ba6b Mon Sep 17 00:00:00 2001 From: Hui Yiqun Date: Thu, 17 Nov 2016 12:33:58 +0800 Subject: [PATCH] add sync script for git-repo --- git-repo.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 git-repo.sh diff --git a/git-repo.sh b/git-repo.sh new file mode 100755 index 0000000..899670b --- /dev/null +++ b/git-repo.sh @@ -0,0 +1,21 @@ +#!/bin/bash +UPSTREAM=${TUNASYNC_UPSTREAM_URL:-"https://gerrit.googlesource.com/git-repo"} + +function repo_init() { + git clone --mirror $UPSTREAM $TUNASYNC_WORKING_DIR +} + +function update_repo_git() { + cd $TUNASYNC_WORKING_DIR + echo "==== SYNC repo.git START ====" + /usr/bin/timeout -s INT 3600 git remote -v update + git repack -a -b -d + echo "==== SYNC repo.git DONE ====" +} + +if [[ ! -f "$TUNASYNC_WORKING_DIR/HEAD" ]]; then + echo "Initializing repo.git mirror" + repo_init +fi + +update_repo_git