changesets-gitlab icon indicating copy to clipboard operation
changesets-gitlab copied to clipboard

Git checkout creates duplicate branches in localized environments

Open YearsAlso opened this issue 6 months ago • 2 comments

Description:
The current switchToMaybeExistingBranch method determines branch checkout success by parsing git checkout command's stderr output. However, since Git client messages vary by system language locale, in non-English environments (e.g., Chinese, Japanese), the stderr.includes() string matching may fail, causing:

  1. False triggering of git checkout -b to recreate existing branches
  2. Potential error: fatal: a branch named 'xxx' already exists

Reproduction Steps:

  1. Set OS/Git language to non-English (e.g., export LANG=zh_CN.UTF-8)
  2. Call switchToMaybeExistingBranch with an existing branch name
  3. Observe git checkout -b being incorrectly triggered with error

Affected Code:
https://github.com/un-ts/changesets-gitlab/blob/main/src/git-utils.ts#L37-L48

Environment:

  • OS: All localization-supported systems
  • Git Versions: All versions affected

YearsAlso avatar May 16 '25 02:05 YearsAlso