mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-07-22 04:15:24 -04:00
[PR #630] [MERGED] Fix stale PR translation revert issue #636
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langgenius/dify-docs/pull/630
Author: @guchenhe
Created: 12/23/2025
Status: ✅ Merged
Merged: 12/24/2025
Merged by: @guchenhe
Base:
main← Head:fix/stale-pr-translation-revert📝 Commits (4)
22e2e8fFix stale PR translation revert issue1c396e3Fix: Use PR's docs.json for finding file positions in navigationd9558d4Fix EN section not updated when using reference_sha861917eAlso remove deleted files from EN section in stale PR scenario📊 Changes
2 files changed (+202 additions, -56 deletions)
View changed files
📝
tools/translate/sync_and_translate.py(+90 -4)📝
tools/translate/translate_pr.py(+112 -52)📄 Description
Summary
Fixes the issue where translation PRs for stale source PRs would revert changes from PRs that were merged after the source PR was created.
Reported scenario:
Example from PR #593:
plugin-logging.mdx)Root Cause
The translation workflow was using the source PR's complete working directory state (which is a snapshot from when that PR branch was created) rather than applying only the PR's net changes on top of the current main branch.
Problematic code in
setup_translation_branch():For incremental branches:
merge_docs_json_for_incremental_update()took the English section from PR HEAD, which was also stale for old PRs.Fix
For NEW branches: Create branch directly from
origin/maininstead of from PR's working directoryFor EXISTING branches: Replace
merge_docs_json_for_incremental_update()with_merge_docs_json_from_main()which:For BOTH: Selectively checkout only the files that the PR actually changed via new
_checkout_pr_changed_files()method, rather than bringing in the entire working directoryChanges
_merge_docs_json_from_main(): New method that merges main's structure with branch's translations_checkout_pr_changed_files(): New method that checkouts only PR's changed source filessetup_translation_branch(): Updated to start from main for new branches, use new merge logic for existingrun_translation_from_sync_plan(): Added call to selective checkoutTesting
Test Plan
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.