Skip to content

Git checkout creates duplicate branches in localized environments #219

@YearsAlso

Description

@YearsAlso

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions