Skip to content

Commit 9994e4f

Browse files
committed
fix: support only report the url in pr change && fix _en.rst's url
1 parent 2f964f4 commit 9994e4f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

ci_scripts/report_preview_url.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,26 @@ generate_preview_url() {
1111
local file_path="$1"
1212
local pr_id="$2"
1313
local path_no_ext="${file_path%.*}"
14-
local base_url="http://preview-pr-${pr_id}.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/"
14+
15+
# Check if file ends with _en (English version)
16+
# _en.rst will only reach English preview, _en.md can be reached in both English and Chinese previews
17+
# To Simplify, we treat all _en files as English version
18+
if [[ "$path_no_ext" == *_en ]]; then
19+
local base_url="http://preview-pr-${pr_id}.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/en/"
20+
else
21+
# Use /zh/ path for Chinese version
22+
local base_url="http://preview-pr-${pr_id}.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/"
23+
fi
24+
1525
local final_url="${base_url}${path_no_ext}.html"
1626
echo "$final_url"
1727
}
1828

19-
mapfile -t all_git_files < <(git diff --name-only --diff-filter=ACMR develop | sed 's#^docs/##')
29+
# Use merge-base to find the common ancestor between PR branch and develop
30+
# This ensures we only get changes from this PR, excluding commits merged to develop after PR creation
31+
BASE_COMMIT=$(git merge-base HEAD develop 2>/dev/null || echo "develop")
32+
33+
mapfile -t all_git_files < <(git diff --name-only --diff-filter=ACMR "$BASE_COMMIT" | sed 's#^docs/##')
2034

2135
output_lines=()
2236

0 commit comments

Comments
 (0)