Skip to content

fix(stack): force C locale on git subprocesses to fix push under non-English locales#1336

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/alexandregaubert/devs/alexandregaubert/fix-stack-push-locale/force-c-locale-git-subprocesses-fix-push-under--a3b14565
May 4, 2026
Merged

fix(stack): force C locale on git subprocesses to fix push under non-English locales#1336
mergify[bot] merged 1 commit into
mainfrom
devs/alexandregaubert/devs/alexandregaubert/fix-stack-push-locale/force-c-locale-git-subprocesses-fix-push-under--a3b14565

Conversation

@AlexandreGaubert
Copy link
Copy Markdown
Contributor

mergify stack push crashed on first push when the user's locale is not
English. fetch_notes_ref and read_reasons match git error output by
substring (e.g. b"couldn't find remote ref", b"no note found"), but
git emits translated messages — under fr_FR git says
fatal : impossible de trouver la référence distante, the substring
check fails, and the exception is re-raised.

Force LC_ALL=C LANG=C LANGUAGE=C on git subprocesses spawned by
run_command and _git_patch_id so the output we parse is stable
regardless of the user's locale. The other git call sites (ci/queue,
ci/scopes, stack/reorder) parse by exit code or null-delimited output
and are deliberately left alone — git rebase -i in particular shows
its messages to the user, and forcing English would degrade UX.

Add a regression test that mocks create_subprocess_exec and asserts
run_command propagates the C-locale env even when the surrounding
shell is fr_FR.

Copilot AI review requested due to automatic review settings May 4, 2026 09:24
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 4, 2026 09:24 Failure
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 4, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make stack push resilient to non-English Git locales by standardizing subprocess locale where stack-related Git output is parsed. It touches the shared async command runner, the git patch-id helper used during stack push, and adds a regression test around environment propagation.

Changes:

  • Added a shared helper to build a subprocess environment with LC_ALL/LANG/LANGUAGE=C.
  • Updated the async command runner and git patch-id subprocess path to pass that environment through.
  • Added a regression test that mocks create_subprocess_exec and verifies the forced locale variables are propagated.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
mergify_cli/utils.py Adds the locale-forcing subprocess environment helper and wires it into the shared async subprocess runner.
mergify_cli/tests/test_utils.py Adds a regression test that checks run_command() forwards the forced C-locale environment.
mergify_cli/stack/push.py Passes the same forced locale environment to the git patch-id subprocess used during stack push change classification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mergify_cli/utils.py
Comment thread mergify_cli/stack/push.py
Comment thread mergify_cli/tests/test_utils.py
jd
jd previously approved these changes May 4, 2026
@mergify mergify Bot requested a review from a team May 4, 2026 09:36
sileht
sileht previously approved these changes May 4, 2026
…English locales

`mergify stack push` crashed on first push when the user's locale is not
English. `fetch_notes_ref` and `read_reasons` match git error output by
substring (e.g. `b"couldn't find remote ref"`, `b"no note found"`), but
git emits translated messages — under fr_FR git says
`fatal : impossible de trouver la référence distante`, the substring
check fails, and the exception is re-raised.

Force `LC_ALL=C LANG=C LANGUAGE=C` on git subprocesses spawned by
`run_command` and `_git_patch_id` so the output we parse is stable
regardless of the user's locale. The other git call sites (ci/queue,
ci/scopes, stack/reorder) parse by exit code or null-delimited output
and are deliberately left alone — `git rebase -i` in particular shows
its messages to the user, and forcing English would degrade UX.

Add a regression test that mocks `create_subprocess_exec` and asserts
`run_command` propagates the C-locale env even when the surrounding
shell is fr_FR.

Change-Id: Ia3b14565355b3031809ce3f2b13f0d145bceeb30
@AlexandreGaubert
Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 800dcbb 2026-05-04 09:43 UTC
2 content 800dcbb → ebe7ceb Add regression test for _git_patch_id locale env propagation (review) 2026-05-04 09:43 UTC

@AlexandreGaubert AlexandreGaubert force-pushed the devs/alexandregaubert/devs/alexandregaubert/fix-stack-push-locale/force-c-locale-git-subprocesses-fix-push-under--a3b14565 branch from 800dcbb to ebe7ceb Compare May 4, 2026 09:43
@mergify mergify Bot dismissed stale reviews from jd and sileht May 4, 2026 09:43

Pull request has been modified.

@mergify mergify Bot deployed to Mergify Merge Protections May 4, 2026 09:43 Active
@mergify mergify Bot requested a review from a team May 4, 2026 09:53
@mergify mergify Bot requested a review from a team May 4, 2026 11:51
@AlexandreGaubert AlexandreGaubert requested a review from sileht May 4, 2026 12:21
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 4, 2026

Merge Queue Status

This pull request spent 12 minutes 4 seconds in the queue, including 11 minutes 44 seconds running CI.

Required conditions to merge

mergify Bot added a commit that referenced this pull request May 4, 2026
@mergify mergify Bot added the queued label May 4, 2026
@mergify mergify Bot merged commit f3a6c7d into main May 4, 2026
22 checks passed
@mergify mergify Bot deleted the devs/alexandregaubert/devs/alexandregaubert/fix-stack-push-locale/force-c-locale-git-subprocesses-fix-push-under--a3b14565 branch May 4, 2026 12:52
@mergify mergify Bot removed the queued label May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants