mirror of
https://gitea.com/gitea/docs.git
synced 2026-06-11 04:31:26 +00:00
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:  After:  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:
committed by
Lunny Xiao
parent
30a23a1ee4
commit
53e27a0e86
50
Makefile
50
Makefile
@@ -7,6 +7,10 @@ all: build
|
|||||||
create_dir:
|
create_dir:
|
||||||
mkdir -p .tmp docs versioned_docs awesome
|
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
|
.PHONY: clone_awesome
|
||||||
clone_awesome: create_dir
|
clone_awesome: create_dir
|
||||||
git clone --branch=main https://gitea.com/gitea/awesome-gitea.git .tmp/upstream-awesome || true
|
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
|
cp .tmp/upstream-awesome/README.md versioned_docs/version-1.$*/awesome.md
|
||||||
|
|
||||||
.PHONY: clone_main
|
.PHONY: clone_main
|
||||||
clone_main: create_dir
|
clone_main: clone
|
||||||
git clone --branch=main https://github.com/go-gitea/gitea.git .tmp/upstream-docs-latest
|
cd .tmp/upstream-docs && git clean -f && git reset --hard && git checkout main
|
||||||
cur_path=`pwd`
|
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)
|
cd $(cur_path)
|
||||||
bash check_outdated.sh latest zh-cn
|
bash check_outdated.sh zh-cn
|
||||||
|
|
||||||
.PHONY: prepare-latest
|
.PHONY: prepare-latest
|
||||||
prepare-latest: clone_main
|
prepare-latest: clone_main
|
||||||
cp -r .tmp/upstream-docs-latest/docs/static/* static/
|
cp -r .tmp/upstream-docs/docs/static/* static/
|
||||||
rsync -avz --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs-latest/docs/content/ docs/
|
rsync -avz --prune-empty-dirs --include '*/' --include='*.en-us.md' --exclude '*' .tmp/upstream-docs/docs/content/ docs/
|
||||||
cp .tmp/upstream-docs-latest/docs/content/index.en-us.md docs/intro.md
|
cp .tmp/upstream-docs/docs/content/index.en-us.md docs/intro.md
|
||||||
cp .tmp/upstream-docs-latest/templates/swagger/v1_json.tmpl static/swagger-latest.json
|
cp .tmp/upstream-docs/templates/swagger/v1_json.tmpl static/swagger-latest.json
|
||||||
bash loop_docs.sh latest en-us
|
bash loop_docs.sh latest en-us
|
||||||
|
|
||||||
.PHONY: prepare-latest-zh-cn
|
.PHONY: prepare-latest-zh-cn
|
||||||
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
|
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/
|
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-latest/docs/content/index.zh-cn.md i18n/zh-cn/docusaurus-plugin-content-docs/current/intro.md
|
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
|
bash loop_docs.sh latest zh-cn
|
||||||
rm -rf .tmp/upstream-docs-latest
|
|
||||||
|
|
||||||
.PHONY: clone_\#%
|
.PHONY: clone_\#%
|
||||||
clone_\#%: create_dir
|
clone_\#%: clone
|
||||||
git clone --branch=release/v1.$* https://github.com/go-gitea/gitea.git .tmp/upstream-docs-$*
|
cd .tmp/upstream-docs && git clean -f && git reset --hard && git checkout release/v1.$*
|
||||||
cur_path=`pwd`
|
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)
|
cd $(cur_path)
|
||||||
bash check_outdated.sh $* zh-cn
|
bash check_outdated.sh zh-cn
|
||||||
|
|
||||||
.PHONY: prepare\#%
|
.PHONY: prepare\#%
|
||||||
prepare\#%: clone_\#%
|
prepare\#%: clone_\#%
|
||||||
cp -r .tmp/upstream-docs-$*/docs/static/* static/
|
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.$*/
|
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/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 .tmp/upstream-docs/templates/swagger/v1_json.tmpl static/swagger-$*.json
|
||||||
bash loop_docs.sh $* en-us
|
bash loop_docs.sh $* en-us
|
||||||
|
|
||||||
.PHONY: prepare-zh-cn\#%
|
.PHONY: prepare-zh-cn\#%
|
||||||
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.$*
|
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.$*/
|
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
|
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
|
bash loop_docs.sh $* zh-cn
|
||||||
rm -rf .tmp/upstream-docs-$*
|
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# The script takes two params:
|
# This script takes `locale` as a param and checks if a specific locale version of document is up to date with English version
|
||||||
# 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
|
|
||||||
# If latest commit timestamp of English version is greater than the specific locale 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
|
# The specific locale version document will be marked as outdated
|
||||||
|
|
||||||
@@ -17,10 +14,9 @@ SED_INPLACE() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
version="$1"
|
locale="$1"
|
||||||
locale="$2"
|
|
||||||
cur_path=`pwd`
|
cur_path=`pwd`
|
||||||
cd .tmp/upstream-docs-"$version"
|
cd .tmp/upstream-docs
|
||||||
|
|
||||||
for file in `find ./docs/content -name "*.${locale}.md"`; do
|
for file in `find ./docs/content -name "*.${locale}.md"`; do
|
||||||
file_en="${file/.${locale}/.en-us}"
|
file_en="${file/.${locale}/.en-us}"
|
||||||
|
|||||||
Reference in New Issue
Block a user