avoid repacking every time

This commit is contained in:
root 2020-03-25 14:55:59 +08:00
parent 00c168ce17
commit 7616d97e4c
5 changed files with 13 additions and 5 deletions

View File

@ -5,6 +5,9 @@ REPO=${REPO:-"/usr/local/bin/repo"}
USE_BITMAP_INDEX=${USE_BITMAP_INDEX:-"0"}
UPSTREAM=${TUNASYNC_UPSTREAM_URL:-"https://android.googlesource.com/mirror/manifest"}
git config --global user.email "mirrors@tuna"
git config --global user.name "tuna mirrors"
function repo_init() {
mkdir -p $TUNASYNC_WORKING_DIR
cd $TUNASYNC_WORKING_DIR
@ -22,7 +25,8 @@ function git_repack() {
cd $repo
size=$(du -sk .|cut -f1)
total_size=$(($total_size+1024*$size))
if [[ "$size" -gt "100000" ]]; then
objs=$(find objects -type f | wc -l)
if [[ "$objs" -gt 8 && "$size" -gt "100000" ]]; then
git repack -a -b -d
fi
done < <(find $TUNASYNC_WORKING_DIR -type d -not -path "*/.repo/*" -name "*.git")

View File

@ -41,7 +41,8 @@ function git_repack() {
cd $repo
size=$(du -sk .|cut -f1)
total_size=$(($total_size+1024*$size))
if [[ "$size" -gt "100000" ]]; then
objs=$(find objects -type f | wc -l)
if [[ "$objs" -gt 8 && "$size" -gt "100000" ]]; then
git repack -a -b -d
fi
done < <(find $TUNASYNC_WORKING_DIR -not -path "$MANIFEST_DIR/.git/*" -type f -name HEAD -exec dirname '{}' ';')

3
git.sh
View File

@ -13,7 +13,8 @@ function update_linux_git() {
cd $TUNASYNC_WORKING_DIR
echo "==== SYNC $UPSTREAM START ===="
/usr/bin/timeout -s INT 3600 git remote -v update
git repack -a -b -d
objs=$(find objects -type f | wc -l)
[[ "$objs" -gt 8 ]] && git repack -a -b -d
sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')
sz=$(($sz*1024))
echo "size-pack:" $(numfmt --to=iec $sz)

View File

@ -10,7 +10,8 @@ function update_homebrew_git() {
cd $repo_dir
echo "==== SYNC $repo_dir START ===="
/usr/bin/timeout -s INT 3600 git remote -v update
git repack -a -b -d
objs=$(find objects/ -type f | wc -l)
[[ "$objs" -gt 8 ]] && git repack -a -b -d
sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')
total_size=$(($total_size+1024*$sz))
echo "==== SYNC $repo_dir DONE ===="

View File

@ -10,7 +10,8 @@ function repo_update() {
cd $repo_dir
echo "==== SYNC $repo_dir START ===="
/usr/bin/timeout -s INT 3600 git remote -v update
git repack -a -b -d
objs=$(find objects/ -type f | wc -l)
[[ "$objs" -gt 8 ]] && git repack -a -b -d
sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')
total_size=$(($total_size+1024*$sz))
echo "==== SYNC $repo_dir DONE ===="