Skip to content

Fix: Force-push to existing sync branch erases human's work-in-progress #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smikitky
Copy link
Member

@smikitky smikitky commented Jun 25, 2025

Currently, the translation sync bot (scripts/sync-translations.js) pushes to the sync-xxxxxxx branch with the --force option:

await exec(`git push --set-upstream --force origin ${syncBranch}`, options);

However, when translation contributors have already started working on translation updates or conflict resolution on the same sync-xxxxxxx branch, a force-push from the script will overwrite their ongoing work in progress.

Problem

  1. The translation bot creates a sync branch named sync-xxxxxxx based on the most recent commit hash of the upstream (English) main branch. It then creates a corresponding sync PR. Currently, this happens every Monday. The sync branch contains conflict markers, and translators are expected to resolve them before merging it into main.

  2. If there have been no updates to the upstream main since the previous Monday, the script generates the same sync-xxxxxxx branch and force-pushes it.

  3. If contributors have already started translation sync work (e.g., resolving conflicts, adding translations, making updates, requesting reviews, or discussing changes) on that sync-xxxxxxx branch, the script's force-push will erase their work.

This problem doesn't surface when the upstream (English) main is updated at least once a week (between two Mondays), which is why I didn't notice it until recently.

What Actually Happened

Currently, the English site's main branch has remained at commit 50d6991 for a few weeks.

  1. On Jun 9, the bot (correctly) created a new PR with many conflict markers: Sync with react.dev @ 50d6991c ja.react.dev#840
  2. On Jun 16, I did the syncing work (resolving conflicts and adding translations), pushed to the sync branch, and requested a review from another Japanese maintainer.
  3. On Jun 19, the other maintainer approved my work.
  4. On Jun 23, the bot force-pushed to the branch, overwriting all my work and restoring all the conflict markers.
  5. A few hours later, I accidentally merged the PR without noticing the bot's force-push. As a result, many conflict markers were merged into main.

Solution

There is no need to use the --force flag. Sync branches are where translators perform substantial manual work. If a branch with the same name already exists and its head hash is different, it indicates that a human translator has modified the sync branch. The bot must not touch it.

@rickhanlonii Please take a look at this

@smikitky
Copy link
Member Author

Another solution might be always using a different branch name (e.g., sync-50d6991c-20250609).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant