[git] set remote url before sync

This commit is contained in:
z4yx 2020-04-27 13:52:55 +08:00
parent 1ade30e85f
commit 2dced2260d
6 changed files with 22 additions and 11 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

5
git.sh
View File

@ -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)

View File

@ -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)

View File

@ -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)