Clone once (#52)

Closes #30
Closes #31
Closes #42

Rather than partially cloning, instead we clone once and then `clean` (to remove generated files), `reset` (to reset changed files), and `checkout` branches as needed. This should allow the outdated translation check to continue to work while also reducing build times significantly.

Before:
![before](/attachments/07c16ef5-110c-451a-9f1b-79f2c8b72caf)

After:
![after](/attachments/d6251f63-087d-4270-946f-63148b8f642a)

Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/52
Co-authored-by: John Olheiser <john+gitea@jolheiser.com>
Co-committed-by: John Olheiser <john+gitea@jolheiser.com>
This commit is contained in:
John Olheiser
2023-07-28 05:52:35 +00:00
committed by Lunny Xiao
parent 30a23a1ee4
commit 53e27a0e86
2 changed files with 27 additions and 33 deletions

View File

@@ -7,6 +7,10 @@ all: build
create_dir:
mkdir -p .tmp docs versioned_docs awesome
.PHONY: clone
clone: create_dir
git clone https://github.com/go-gitea/gitea.git .tmp/upstream-docs || true
.PHONY: clone_awesome
clone_awesome: create_dir
git clone --branch=main https://gitea.com/gitea/awesome-gitea.git .tmp/upstream-awesome || true
@@ -20,56 +24,50 @@ prepare-awesome\#%:
cp .tmp/upstream-awesome/README.md versioned_docs/version-1.$*/awesome.md
.PHONY: clone_main
clone_main: create_dir
git clone --branch=main https://github.com/go-gitea/gitea.git .tmp/upstream-docs-latest
clone_main: clone
cd .tmp/upstream-docs && git clean -f && git reset --hard && git checkout main
cur_path=`pwd`
cd .tmp/upstream-docs-latest/docs && bash scripts/trans-copy.sh
cd .tmp/upstream-docs/docs && bash scripts/trans-copy.sh
cd $(cur_path)
bash check_outdated.sh latest zh-cn
bash check_outdated.sh zh-cn
.PHONY: prepare-latest
prepare-latest: clone_main
cp -r .tmp/upstream-docs-latest/docs/static/* static/
rsync -avz --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs-latest/docs/content/ docs/
cp .tmp/upstream-docs-latest/docs/content/index.en-us.md docs/intro.md
cp .tmp/upstream-docs-latest/templates/swagger/v1_json.tmpl static/swagger-latest.json
cp -r .tmp/upstream-docs/docs/static/* static/
rsync -avz --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs/docs/content/ docs/
cp .tmp/upstream-docs/docs/content/index.en-us.md docs/intro.md
cp .tmp/upstream-docs/templates/swagger/v1_json.tmpl static/swagger-latest.json
bash loop_docs.sh latest en-us
.PHONY: prepare-latest-zh-cn
prepare-latest-zh-cn:
# clone_main
# cp -r .tmp/upstream-docs-latest/docs/static/* static/
mkdir -p i18n/zh-cn/docusaurus-plugin-content-docs/current
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-latest/docs/content/ i18n/zh-cn/docusaurus-plugin-content-docs/current/
cp .tmp/upstream-docs-latest/docs/content/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs/docs/content/ i18n/zh-cn/docusaurus-plugin-content-docs/current/
cp .tmp/upstream-docs/docs/content/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md
bash loop_docs.sh latest zh-cn
rm -rf .tmp/upstream-docs-latest
.PHONY: clone_\#%
clone_\#%: create_dir
git clone --branch=release/v1.$* https://github.com/go-gitea/gitea.git .tmp/upstream-docs-$*
clone_\#%: clone
cd .tmp/upstream-docs && git clean -f && git reset --hard && git checkout release/v1.$*
cur_path=`pwd`
cd .tmp/upstream-docs-$*/docs && bash scripts/trans-copy.sh
cd .tmp/upstream-docs/docs && bash scripts/trans-copy.sh
cd $(cur_path)
bash check_outdated.sh $* zh-cn
bash check_outdated.sh zh-cn
.PHONY: prepare\#%
prepare\#%: clone_\#%
cp -r .tmp/upstream-docs-$*/docs/static/* static/
rsync -a --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs-$*/docs/content/ versioned_docs/version-1.$*/
cp .tmp/upstream-docs-$*/docs/content/index.en-us.md versioned_docs/version-1.$*/intro.md
cp .tmp/upstream-docs-$*/templates/swagger/v1_json.tmpl static/swagger-$*.json
cp -r .tmp/upstream-docs/docs/static/* static/
rsync -a --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs/docs/content/ versioned_docs/version-1.$*/
cp .tmp/upstream-docs/docs/content/index.en-us.md versioned_docs/version-1.$*/intro.md
cp .tmp/upstream-docs/templates/swagger/v1_json.tmpl static/swagger-$*.json
bash loop_docs.sh $* en-us
.PHONY: prepare-zh-cn\#%
prepare-zh-cn\#%:
# clone_\#%
# cp -r .tmp/upstream-docs-$*/docs/static/* static/
mkdir -p i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs-$*/docs/content/ i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/
cp .tmp/upstream-docs-$*/docs/content/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/intro.md
rsync -avz --prune-empty-dirs --include '*/' --include='*.zh-cn.md' --exclude '*' .tmp/upstream-docs/docs/content/ i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/
cp .tmp/upstream-docs/docs/content/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/version-1.$*/intro.md
bash loop_docs.sh $* zh-cn
rm -rf .tmp/upstream-docs-$*
.PHONY: install
install:

View File

@@ -1,9 +1,6 @@
#!/bin/bash
# The script takes two params:
# version: "latest" or a specific version number
# locale
# This script checks if a specific locale version of document is up to date with English version
# This script takes `locale` as a param and checks if a specific locale version of document is up to date with English version
# If latest commit timestamp of English version is greater than the specific locale version,
# The specific locale version document will be marked as outdated
@@ -17,10 +14,9 @@ SED_INPLACE() {
fi
}
version="$1"
locale="$2"
locale="$1"
cur_path=`pwd`
cd .tmp/upstream-docs-"$version"
cd .tmp/upstream-docs
for file in `find ./docs/content -name "*.${locale}.md"`; do
file_en="${file/.${locale}/.en-us}"