@@ -33,29 +33,37 @@ git update-index --index-version 4
3333sudonot chmod -R a+rwX .
3434sudonot find . -type d -exec chmod g+s ' {}' +
3535
36- if git ls-remote --exit-code origin index & > /dev/null; then
37- git worktree remove -f index.bak & > /dev/null
38- [ -d index.bak ] || rm -rf index.bak
39- git worktree move index index.bak & > /dev/null
40- git fetch origin index
36+ curr=$( git branch --show-current 2> /dev/null)
37+ index=" index$( [ " $GITHUB_BRANCH " = " master" ] && echo " " || echo " -${curr:- master} " ) "
38+ BKG_INDEX_DB=$BKG_ROOT /" $index " .db
39+ BKG_INDEX_SQL=$BKG_ROOT /" $index " .sql
40+ BKG_INDEX_DIR=$BKG_ROOT /" $index "
41+
42+ if git ls-remote --exit-code origin " $index " & > /dev/null; then
43+ git worktree remove -f " $index " .bak & > /dev/null
44+ [ -d " $index " .bak ] || rm -rf " $index " .bak
45+ git worktree move " $index " " $index " .bak & > /dev/null
46+ git fetch origin " $index "
4147 BKG_IS_FIRST=true
4248else
4349 fd_list=$( find . -type f -o -type d | grep -vE " ^\.($|\/(\.git\/*|.*\.md$))" )
44- git switch --orphan index
50+ git stash
51+ git switch --orphan " $index "
4552 xargs rm -rf <<< " $fd_list"
4653 git add .
4754 git commit --allow-empty -m " init index"
48- git push -u origin index
49- git checkout master
55+ git push -u origin " $index "
56+ git checkout " $( [ -n " $GITHUB_BRANCH " ] && echo " $GITHUB_BRANCH " || echo " $curr " ) "
57+ git stash pop || true
5058fi
5159
52- git worktree remove -f index 2> /dev/null
53- git worktree add -f index index
54- [[ -d index || ! -d index.bak ]] || git worktree move index.bak index
55- pushd index || exit 1
56- git reset --hard origin/index
60+ git worktree remove -f " $ index" 2> /dev/null
61+ git worktree add -f " $ index" " $ index"
62+ [[ -d " $ index" || ! -d " $ index" .bak ]] || git worktree move " $ index" .bak " $ index"
63+ pushd " $ index" || exit 1
64+ git reset --hard origin/" $ index"
5765popd || exit 1
58- [ -f index/.env ] && \c p index/.env src/env.env || touch src/env.env
66+ [ -f " $ index" /.env ] && \c p " $ index" /.env src/env.env || touch src/env.env
5967pushd src || exit 1
6068
6169db_size=$( stat -c %s " $BKG_INDEX_SQL " .zst)
@@ -76,15 +84,15 @@ return_code=$?
7684# files should be valid, warn if not, unless only opted out owners
7785# (( return_code == 1 )) || find .. -type f -name '*.json' -o -name '*.xml' | parallel --lb test/index.sh {}
7886popd || exit 1
79- \c p src/env.env index/.env
87+ \c p src/env.env " $ index" /.env
8088
81- if git worktree list | grep -q index; then
82- pushd index || exit 1
89+ if git worktree list | grep -q " $ index" ; then
90+ pushd " $ index" || exit 1
8391 git add .
8492 git commit -m " $( date -u +%Y-%m-%d) "
8593 git push
8694 popd || exit 1
87- ! git worktree list | grep -q index.bak || git worktree remove -f index.bak & > /dev/null
95+ ! git worktree list | grep -q " $ index" .bak || git worktree remove -f " $ index" .bak & > /dev/null
8896fi
8997
9098(git pull --rebase --autostash 2> /dev/null)
0 commit comments