glab stack sync fails with non-English Git output
Checklist
-
I'm using the latest version of the extension (Run glab --version)- Extension version: 1.48.0 (2024-10-16)
-
Operating system and version: macOS 13.3.1 -
Gitlab.com or self-managed instance? self-managed instance -
GitLab version (if self-managed) v17.5.0 (Use the versionendpoint, like this: gitlab.my-company.com/api/v4/version) -
I have performed glab auth statusto check for authentication issues
Summary
The glab stack sync command fails when Git outputs localized (non-English) messages. This occurs because the command checks for specific English strings (e.g., "nothing to commit") but doesn't handle localized output, resulting in incorrect branch status detection.
- OS: Darwin 22.4.0 arm64
- SHELL: /bin/zsh
- TERM: xterm-256color
- GLAB: Current glab version: 1.48.0 (2024-10-16)
Other:
Steps to reproduce
- Set system language to non-English (e.g., Korean)
- Create a stack using
glab stack create - Make some changes and commit them
- Push the changes to remote
- Run
glab stack sync - The command fails even when the branch is up-to-date
What is the current bug behavior?
The command fails with the error "your Git branch is ahead, but it shouldn't be. You might need to squash your commits." even when the branch is properly synchronized with remote.
With DEBUG=1, we can see:
[git remote -v]
[git config --get-regexp ^remote\..*\.glab-resolved$]
[git remote -v]
| Syncing[git config --get-regexp ^remote\..*\.glab-resolved$]
[git remote -v]
[git config --get-regexp ^remote\..*\.glab-resolved$]
[git remote -v]
[git config --get-regexp ^remote\..*\.glab-resolved$]
[git config --get-all remote.origin.glab-resolved]
[git remote -v]
[git config --get-regexp ^remote\..*\.glab-resolved$]
[git remote -v]
[git config --get-regexp ^remote\..*\.glab-resolved$]
[git config glab.currentstack]
| Syncing[git rev-parse --show-toplevel]
[git fetch origin]
/ Syncing2024/11/08 11:58:10 [Fetching from remote: ]
[git checkout jeondaeseong-stack-test-677ec230]
2024/11/08 11:58:10 [Checked out: 브랜치가 'origin/jeondaeseong-stack-test-677ec230'에 맞게 업데이트된 상태입니다.
]
[git status -uno]
2024/11/08 11:58:10 [Git status: 현재 브랜치 jeondaeseong-stack-test-677ec230
브랜치가 'origin/jeondaeseong-stack-test-677ec230'에 맞게 업데이트된 상태입니다.
커밋할 사항 없음 (추적하지 않는 파일을 보려면 -u 옵션을 사용하십시오)
]
could not run sync: your Git branch is ahead, but it shouldn't be. You might need to squash your commits.
What is the expected correct behavior?
The command should either:
- Force Git to output English messages using LANG=C
- Or handle localized messages properly
- Successfully complete the sync operation
❯ LANG=C glab stack sync
/ Syncing
• jeondaeseong-stack-test-677ec230 needs a merge request. Creating it now.
- Syncing
• Merge request created!
!5 change (jeondaeseong-stack-test-677ec230)
https://gitlab.example.com/group/ds/fe-monorepo/-/merge_requests/5
\ Syncing
• jeondaeseong-stack-test-dfd286bb needs a merge request. Creating it now.
| Syncing
• Merge request created!
Relevant logs and/or screenshots
Possible fixes
The issue appears to be in the branch status checking logic where it looks for specific English strings: https://gitlab.com/gitlab-org/cli/-/blob/main/commands/stack/sync/sync.go
The code checks for constants like:
const (
branchIsBehind = "Your branch is behind"
branchHasDiverged = "have diverged"
nothingToCommit = "nothing to commit"
)
But doesn't handle localized versions of these messages.