mirror of
https://github.com/tldr-pages/tldr.git
synced 2026-10-29 18:05:30 +08:00
scripts/check-pr.sh: add header check (#20212)
Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>
This commit is contained in:
co-authored by
Sebastiaan Speck
parent
8180331ef2
commit
7bfa274864
@@ -87,6 +87,13 @@ function count_commands() {
|
||||
grep -c "$regex" "$file"
|
||||
}
|
||||
|
||||
count_header() {
|
||||
local file="$1"
|
||||
local regex="$2"
|
||||
|
||||
grep -c "$regex" "$file"
|
||||
}
|
||||
|
||||
function strip_commands() {
|
||||
local file="$1"
|
||||
local regex="$2"
|
||||
@@ -112,6 +119,7 @@ function check_outdated_page() {
|
||||
local page="$1"
|
||||
local english_page="pages/${page#pages*\/}"
|
||||
local command_regex='^`[^`]\+`$'
|
||||
local header_regex='^>.*$'
|
||||
|
||||
if [[ $page == "$english_page" || ! -f $english_page ]]; then
|
||||
return 1
|
||||
@@ -128,6 +136,12 @@ function check_outdated_page() {
|
||||
elif [[ "$english_commands_as_string" != "$commands_as_string" ]]; then
|
||||
printf "\x2d $MSG_OUTDATED" "$page" "based on the command contents itself"
|
||||
fi
|
||||
|
||||
english_header_lines=$(count_header "$english_page" "$header_regex")
|
||||
header_lines=$(count_header "$page" "$header_regex")
|
||||
if [[ "$english_header_lines" != "$header_lines" ]]; then
|
||||
printf "\x2d $MSG_OUTDATED" "$page" "based on number of header lines"
|
||||
fi
|
||||
}
|
||||
|
||||
function check_more_info_link() {
|
||||
|
||||
Reference in New Issue
Block a user