2024-11-30
This commit is contained in:
parent
4339539c68
commit
fa7f621960
3 changed files with 12 additions and 5 deletions
|
@ -7,6 +7,6 @@ time_ms="$(date '+%s%3N')"
|
|||
find . -mindepth 1 -maxdepth 1 -type d -not -name ".idea" | while read -r dir; do
|
||||
echo "Обработка: $dir"
|
||||
# внутри репозитория — удаление всех вложенных файлов и папок, кроме папки ".git"
|
||||
find "$dir" -mindepth 1 -maxdepth 1 -type f,d -not -name ".git" -print0 | xargs -0 rm -r
|
||||
find "$dir" -mindepth 1 -maxdepth 1 -type f,d -not -name ".git" -exec rm -r {} \;
|
||||
done
|
||||
echo "Общее время выполнения: $(("$(date '+%s%3N')" - "$time_ms")) мс."
|
||||
|
|
|
@ -4,6 +4,10 @@ fi
|
|||
echo "Создание локального репозитория, подключение к удалённому и передача данных."
|
||||
seconds=3
|
||||
time_ms="$(date '+%s%3N')"
|
||||
# строка исключений для "find" из списка ".gitignore" — неотслеживаемые файлы
|
||||
exclusions="-not -path '*/.git/*' $(sed -E "s|^(.*)$|-not -path '*/\1*'|" .gitignore | tr '\n' ' ')"
|
||||
# перевести размеры файла в человеко-читаемую строку, отбросить нули из дробной части и добавить пробел
|
||||
function BKM { numfmt --to=iec --format="%.2f" --suffix="B" "$1" | sed -r 's|,{,1}0{,2}([BKM])| \1|'; }
|
||||
rm -rf .git
|
||||
git init -b master
|
||||
git remote add "$domain" "git@$domain:$owner/$repo.git"
|
||||
|
@ -44,7 +48,7 @@ git commit -m "Картинки"
|
|||
while read -r file size; do
|
||||
echo "Обработка: $file"
|
||||
git add "$file"
|
||||
git commit -m "${file#*/} / $(numfmt --to=iec --format="%.2f" --suffix="B" "$size" | sed -E 's|,{,1}0{,2}([BKM])| \1|')"
|
||||
done < <(find . -type f -not -path "*/.*" -not -path "./_site*" -printf '%h/%f %s\n' | LC_COLLATE=C sort -r)
|
||||
git commit -m "${file#*/} / $(BKM "$size")"
|
||||
done < <(eval "find . -type f $exclusions -printf '%h/%f %s\n'" | LC_COLLATE=C sort -r)
|
||||
git push -u "$domain" master
|
||||
echo "Общее время выполнения: $(("$(date '+%s%3N')" - "$time_ms")) мс."
|
||||
|
|
|
@ -12,8 +12,11 @@ find . -mindepth 1 -maxdepth 1 -type d -printf \
|
|||
# 2 Создание репозиториев на сервере
|
||||
find . -mindepth 1 -maxdepth 1 -type d -printf \
|
||||
'cd %h/%f && ./.repo_remote.sh "create" >>.repo_remote.log\0' | xargs -L1 -0 -P0 bash -c
|
||||
# 3 Создание локальных репозиториев и отправка данных на сервер
|
||||
# 4 Изменение настроек репозиториев на сервере, отключение ненужного
|
||||
# 3 Проверка корректности пересоздания репозиториев на сервере — выход в случае ошибки
|
||||
find . -mindepth 2 -maxdepth 2 -type f -name ".repo_remote.log" -exec grep -cE '^HTTP\/[1,2].{,2}? [4,5]' {} \; |
|
||||
tr -d '0\n' | xargs -r bash -c 'exit 1' || { echo "Ошибка 400-500. Невозможно подключение к серверу." && exit 1; }
|
||||
# 4 Создание локальных репозиториев и отправка данных на сервер
|
||||
# 5 Изменение настроек репозиториев на сервере, отключение ненужного
|
||||
find . -mindepth 1 -maxdepth 1 -type d -printf \
|
||||
'cd %h/%f && ./.repo_local.sh >.repo_local.log\0
|
||||
cd %h/%f && ./.repo_remote.sh "options" >>.repo_remote.log\0' | xargs -L1 -0 -P0 bash -c
|
||||
|
|
Loading…
Add table
Reference in a new issue