From 2dced2260d7c92f6eb26da045678d4abd19ba0ca Mon Sep 17 00:00:00 2001 From: z4yx Date: Mon, 27 Apr 2020 13:52:55 +0800 Subject: [PATCH] [git] set remote url before sync --- adobe-fonts.sh | 6 ++++-- cocoapods.sh | 6 ++++-- git-repo.sh | 1 + git.sh | 5 +++-- homebrew.sh | 9 ++++++--- llvm.sh | 6 ++++-- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/adobe-fonts.sh b/adobe-fonts.sh index 83fef63..887dbf8 100755 --- a/adobe-fonts.sh +++ b/adobe-fonts.sh @@ -10,9 +10,11 @@ function repo_init() { } function update_font_git() { - repo_dir="$1" + UPSTREAM="$1" + repo_dir="$2" cd "$repo_dir" echo "==== SYNC $repo_dir START ====" + git remote set-url origin "$UPSTREAM" /usr/bin/timeout -s INT 3600 git remote -v update -p git remote set-head origin --auto objs=$(find objects -type f | wc -l) @@ -44,7 +46,7 @@ for repo in ${REPOS[@]}; do echo "Initializing ${repo}.git" repo_init "${UPSTREAM_BASE}/${repo}.git" "$TUNASYNC_WORKING_DIR/${repo}.git" fi - update_font_git "$TUNASYNC_WORKING_DIR/${repo}.git" + update_font_git "${UPSTREAM_BASE}/${repo}.git" "$TUNASYNC_WORKING_DIR/${repo}.git" checkout_font_branch "$TUNASYNC_WORKING_DIR/${repo}.git" "$TUNASYNC_WORKING_DIR/${repo}" "release" done diff --git a/cocoapods.sh b/cocoapods.sh index a561143..077cc75 100755 --- a/cocoapods.sh +++ b/cocoapods.sh @@ -8,9 +8,11 @@ function repo_init() { } function update_cocoapods_git() { - repo_dir="$1" + UPSTREAM="$1" + repo_dir="$2" cd $repo_dir echo "==== SYNC $repo_dir START ====" + git remote set-url origin "$UPSTREAM" /usr/bin/timeout -s INT 3600 git remote -v update -p git remote set-head origin --auto objs=$(find objects -type f | wc -l) @@ -29,7 +31,7 @@ for repo in ${REPOS[@]}; do echo "Initializing ${repo}.git" repo_init "${UPSTREAM_BASE}/${repo}.git" "$TUNASYNC_WORKING_DIR/${repo}.git" fi - update_cocoapods_git "$TUNASYNC_WORKING_DIR/${repo}.git" + update_cocoapods_git "${UPSTREAM_BASE}/${repo}.git" "$TUNASYNC_WORKING_DIR/${repo}.git" done echo "Total size is" $(numfmt --to=iec $total_size) diff --git a/git-repo.sh b/git-repo.sh index 490286e..579187d 100755 --- a/git-repo.sh +++ b/git-repo.sh @@ -8,6 +8,7 @@ function repo_init() { function update_repo_git() { cd $TUNASYNC_WORKING_DIR echo "==== SYNC repo.git START ====" + git remote set-url origin "$UPSTREAM" /usr/bin/timeout -s INT 3600 git remote -v update -p git remote set-head origin --auto git repack -a -b -d diff --git a/git.sh b/git.sh index 482279e..7868367 100755 --- a/git.sh +++ b/git.sh @@ -6,12 +6,13 @@ if [[ -z "$UPSTREAM" ]];then fi function repo_init() { - git clone --mirror $UPSTREAM $TUNASYNC_WORKING_DIR + git clone --mirror "$UPSTREAM" "$TUNASYNC_WORKING_DIR" } function update_linux_git() { - cd $TUNASYNC_WORKING_DIR + cd "$TUNASYNC_WORKING_DIR" echo "==== SYNC $UPSTREAM START ====" + git remote set-url origin "$UPSTREAM" /usr/bin/timeout -s INT 3600 git remote -v update -p git remote set-head origin --auto objs=$(find objects -type f | wc -l) diff --git a/homebrew.sh b/homebrew.sh index 995f248..a1b7282 100755 --- a/homebrew.sh +++ b/homebrew.sh @@ -6,9 +6,11 @@ function repo_init() { } function update_homebrew_git() { - repo_dir="$1" + UPSTREAM="$1" + repo_dir="$2" cd $repo_dir echo "==== SYNC $repo_dir START ====" + git remote set-url origin "$UPSTREAM" /usr/bin/timeout -s INT 3600 git remote -v update -p git remote set-head origin --auto objs=$(find objects/ -type f | wc -l) @@ -18,15 +20,16 @@ function update_homebrew_git() { echo "==== SYNC $repo_dir DONE ====" } +UPSTREAM_BASE=${TUNASYNC_UPSTREAM_URL:-"https://github.com/Homebrew"} brews=("brew" "homebrew-core" "homebrew-cask" "homebrew-cask-fonts" "homebrew-cask-drivers" "linuxbrew-core") total_size=0 for brew in ${brews[@]}; do if [[ ! -d "$TUNASYNC_WORKING_DIR/${brew}.git" ]]; then echo "Initializing ${brew}.git" - repo_init "https://github.com/Homebrew/${brew}.git" "$TUNASYNC_WORKING_DIR/${brew}.git" + repo_init "${UPSTREAM_BASE}/${brew}.git" "$TUNASYNC_WORKING_DIR/${brew}.git" fi - update_homebrew_git "$TUNASYNC_WORKING_DIR/${brew}.git" + update_homebrew_git "${UPSTREAM_BASE}/${brew}.git" "$TUNASYNC_WORKING_DIR/${brew}.git" done echo "Total size is" $(numfmt --to=iec $total_size) diff --git a/llvm.sh b/llvm.sh index c534276..cc83902 100755 --- a/llvm.sh +++ b/llvm.sh @@ -6,9 +6,11 @@ function repo_init() { } function repo_update() { - repo_dir="$1" + UPSTREAM=$1 + repo_dir="$2" cd $repo_dir echo "==== SYNC $repo_dir START ====" + git remote set-url origin "$UPSTREAM" /usr/bin/timeout -s INT 3600 git remote -v update -p git remote set-head origin --auto objs=$(find objects/ -type f | wc -l) @@ -27,7 +29,7 @@ for repo in ${repos[@]}; do echo "Initializing ${repo}.git" repo_init "${UPSTREAM_BASE}/${repo}" "$TUNASYNC_WORKING_DIR/${repo}.git" fi - repo_update "$TUNASYNC_WORKING_DIR/${repo}.git" + repo_update "${UPSTREAM_BASE}/${repo}" "$TUNASYNC_WORKING_DIR/${repo}.git" done echo "Total size is" $(numfmt --to=iec $total_size)