1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-01 23:55:26 +02:00

check-pr: add check to see if English page exists (#11470)

This commit is contained in:
Sebastiaan Speck 2023-11-12 10:48:15 +01:00 committed by GitHub
parent 159626c127
commit 75d9f61819
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,8 @@
# they already exist under 'common'. # they already exist under 'common'.
# 3. Detect pages that were added in the 'common' platform although they # 3. Detect pages that were added in the 'common' platform although they
# already exist under a platform specific directory. # already exist under a platform specific directory.
# 4. Detect other miscellaneous anomalies in the pages folder. # 4. Detect pages that do not exist as English pages yet.
# 5. Detect other miscellaneous anomalies in the pages folder.
# #
# Results are printed to stdout, logs and errors to stderr. # Results are printed to stdout, logs and errors to stderr.
# #
@ -44,6 +45,15 @@ function check_duplicates {
esac esac
} }
function check_missing_english_page() {
local page="$1"
local english_page="pages/${page#pages*\/}"
if [[ ! -f "$english_page" ]]; then
printf "\x2d $MSG_NOT_EXISTS" "$page" "$english_page"
fi
}
# Look at git diff and check for copied/duplicated pages. # Look at git diff and check for copied/duplicated pages.
function check_diff { function check_diff {
local git_diff local git_diff
@ -77,6 +87,7 @@ function check_diff {
A) # file1 was newly added A) # file1 was newly added
check_duplicates "$file1" check_duplicates "$file1"
check_missing_english_page "$file1"
;; ;;
esac esac
done <<< "$git_diff" done <<< "$git_diff"
@ -104,6 +115,7 @@ function check_structure {
################################### ###################################
MSG_EXISTS='The page `%s` already exists under the `%s` platform.\n' MSG_EXISTS='The page `%s` already exists under the `%s` platform.\n'
MSG_NOT_EXISTS='The page `%s` does not exists as English page `%s` yet.\n'
MSG_IS_COPY='The page `%s` seems to be a copy of `%s` (%d%% matching).\n' MSG_IS_COPY='The page `%s` seems to be a copy of `%s` (%d%% matching).\n'
MSG_NOT_DIR='The file `%s` does not look like a directory.\n' MSG_NOT_DIR='The file `%s` does not look like a directory.\n'
MSG_NOT_FILE='The file `%s` does not look like a regular file.\n' MSG_NOT_FILE='The file `%s` does not look like a regular file.\n'