change lineending

This commit is contained in:
techknowlogick
2023-10-06 18:36:30 -04:00
parent 8dc5241fbd
commit 83fd2e9b8b

View File

@@ -1,93 +1,93 @@
#!/bin/bash #!/bin/bash
# The script takes two params: # The script takes two params:
# version: "latest" or a specific version number # version: "latest" or a specific version number
# locale # locale
set -xe set -xe
SED_INPLACE() { SED_INPLACE() {
if sed --version 2>/dev/null | grep -q GNU; then if sed --version 2>/dev/null | grep -q GNU; then
sed -i "$@" sed -i "$@"
else else
sed -i '' "$@" sed -i '' "$@"
fi fi
} }
version="$1" version="$1"
if [ "$version" != "latest" ]; then if [ "$version" != "latest" ]; then
version="1.$1" version="1.$1"
fi fi
locale="$2" locale="$2"
minNodeVer="16" minNodeVer="16"
minGoVer="1.20" minGoVer="1.20"
goVer="1.20" goVer="1.20"
minorVer="main-nightly" minorVer="main-nightly"
if [ "$version" == "1.19" ]; then if [ "$version" == "1.19" ]; then
minorVer="1.19.4" minorVer="1.19.4"
minGoVer="1.19" minGoVer="1.19"
elif [ "$version" == "1.20" ]; then elif [ "$version" == "1.20" ]; then
minorVer="1.20.5" minorVer="1.20.5"
elif [ "$version" == "1.21" ]; then elif [ "$version" == "1.21" ]; then
minorVer="1.21.0-rc1" minorVer="1.21.0-rc1"
fi fi
docs_dir="versioned_docs/version-$version" docs_dir="versioned_docs/version-$version"
if [ "$version" == "latest" ]; then if [ "$version" == "latest" ]; then
if [ "$locale" == "en-us" ]; then if [ "$locale" == "en-us" ]; then
docs_dir="docs" docs_dir="docs"
else else
docs_dir="i18n/$locale/docusaurus-plugin-content-docs/current" docs_dir="i18n/$locale/docusaurus-plugin-content-docs/current"
fi fi
else else
if [ "$locale" != "en-us" ]; then if [ "$locale" != "en-us" ]; then
docs_dir="i18n/$locale/docusaurus-plugin-content-docs/version-$version" docs_dir="i18n/$locale/docusaurus-plugin-content-docs/version-$version"
fi fi
fi fi
SED_INPLACE "s/@minNodeVersion@/$minNodeVer/" "$docs_dir/development/hacking-on-gitea.$locale.md" SED_INPLACE "s/@minNodeVersion@/$minNodeVer/" "$docs_dir/development/hacking-on-gitea.$locale.md"
SED_INPLACE "s/@minGoVersion@/$minGoVer/" "$docs_dir/development/hacking-on-gitea.$locale.md" SED_INPLACE "s/@minGoVersion@/$minGoVer/" "$docs_dir/development/hacking-on-gitea.$locale.md"
SED_INPLACE "s/@goVersion@/$goVer/" "$docs_dir/development/hacking-on-gitea.$locale.md" SED_INPLACE "s/@goVersion@/$goVer/" "$docs_dir/development/hacking-on-gitea.$locale.md"
SED_INPLACE "s/@minNodeVersion@/$minNodeVer/" "$docs_dir/installation/from-source.$locale.md" SED_INPLACE "s/@minNodeVersion@/$minNodeVer/" "$docs_dir/installation/from-source.$locale.md"
SED_INPLACE "s/@minGoVersion@/$minGoVer/" "$docs_dir/installation/from-source.$locale.md" SED_INPLACE "s/@minGoVersion@/$minGoVer/" "$docs_dir/installation/from-source.$locale.md"
# TODO: improve this sed # TODO: improve this sed
# need confirmation # need confirmation
if [ "$version" == "latest" ]; then if [ "$version" == "latest" ]; then
SED_INPLACE 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.22-dev"/' static/swagger-latest.json SED_INPLACE 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.22-dev"/' static/swagger-latest.json
elif [ "$version" == "1.21" ]; then elif [ "$version" == "1.21" ]; then
SED_INPLACE 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.21.0-rc0"/' static/swagger-21.json SED_INPLACE 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.21.0-rc0"/' static/swagger-21.json
elif [ "$version" == "1.20" ]; then elif [ "$version" == "1.20" ]; then
SED_INPLACE 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.20.4"/' static/swagger-20.json SED_INPLACE 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.20.4"/' static/swagger-20.json
elif [ "$version" == "1.19" ]; then elif [ "$version" == "1.19" ]; then
SED_INPLACE 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.19.4"/' static/swagger-19.json SED_INPLACE 's/"version": "{{AppVer | JSEscape | Safe}}"/"version": "1.19.4"/' static/swagger-19.json
fi fi
SED_INPLACE 's/"basePath": "{{AppSubUrl | JSEscape | Safe}}/"basePath": "https:\/\/gitea.com/' static/swagger-"$1".json SED_INPLACE 's/"basePath": "{{AppSubUrl | JSEscape | Safe}}/"basePath": "https:\/\/gitea.com/' static/swagger-"$1".json
for file in `find ./"$docs_dir" -name "*.md"`; do for file in `find ./"$docs_dir" -name "*.md"`; do
if [ "$version" == "lastest" ]; then if [ "$version" == "lastest" ]; then
SED_INPLACE 's/dl.gitea.com\/gitea\/@version@/dl.gitea.com\/gitea\/main/g' $file SED_INPLACE 's/dl.gitea.com\/gitea\/@version@/dl.gitea.com\/gitea\/main/g' $file
SED_INPLACE 's/gitea\/gitea\:@version@/gitea\/gitea\:nightly/g' $file SED_INPLACE 's/gitea\/gitea\:@version@/gitea\/gitea\:nightly/g' $file
fi fi
SED_INPLACE "s/@version@/$minorVer/g" $file SED_INPLACE "s/@version@/$minorVer/g" $file
done done
for file in "$docs_dir"/*; do for file in "$docs_dir"/*; do
if [ -d $file ]; then if [ -d $file ]; then
continue continue
fi fi
if [ "$file" == "$docs_dir/intro.md" ]; then if [ "$file" == "$docs_dir/intro.md" ]; then
continue continue
fi fi
rm $file || true rm $file || true
done done
# file names under docs/ and i18n/zh-cn/docusaurus-plugin-content-docs/current/ should be the same for docusaurus # file names under docs/ and i18n/zh-cn/docusaurus-plugin-content-docs/current/ should be the same for docusaurus
# to recognize them as tanslated. # to recognize them as tanslated.
for file in `find "$docs_dir" -name "*.$locale.md"`; do for file in `find "$docs_dir" -name "*.$locale.md"`; do
mv "${file}" "${file/.$locale/}" mv "${file}" "${file/.$locale/}"
done done
if [ -f "$docs_dir/help/search.md" ]; then if [ -f "$docs_dir/help/search.md" ]; then
rm "$docs_dir/help/search.md" rm "$docs_dir/help/search.md"
fi fi