Skip to content

fix(git): force the default git locale on methods relying on parsing the output #1012

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

Merged
merged 3 commits into from
Mar 11, 2024

Conversation

noirbizarre
Copy link
Member

Description

This change ensure that methods relying on localized git output parsing use the default locale instead of the one defined by the user.

Currently, there was only on, git.get_tags() when no commit exists. This PR ensure the command is run with the default C locale (meaning no locale). Currently, it was failing to handle this case on non-english system and producing 2 test failures on non-english system.

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes (N/A)

Expected behavior

Command output parsing works whatever the user locale.
Test runs and succeed whatever the user locale.

Steps to Test This Pull Request

Define your environment locale (LANG/LANGUAGE/LC_ALL depending on the OS, shell ...) to anything else than en_* locale or C locale and then:

  • run the test suite: it should succeed
  • run the cz changelog command on a repository without commits: it should succeed

Additional context

I choose to set the environment variables only on the command relying on localized output parsing. Benefit: any other call is localized and user can read potential failures in its own language. Drawback: devs should think about localization and forcing locale each time they want to parse a localized output.

Potential alternatives:

  • force all command to run in their default language
  • force all git calls to run in git default locale

Copy link

codecov bot commented Mar 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.45%. Comparing base (120d514) to head (8759a73).
Report is 205 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1012      +/-   ##
==========================================
+ Coverage   97.33%   97.45%   +0.11%     
==========================================
  Files          42       55      +13     
  Lines        2104     2395     +291     
==========================================
+ Hits         2048     2334     +286     
- Misses         56       61       +5     
Flag Coverage Δ
unittests 97.45% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@noirbizarre noirbizarre force-pushed the fix/git-parsing-lang branch from 0b07961 to df74d72 Compare March 9, 2024 18:37
@noirbizarre noirbizarre merged commit 6654ef1 into commitizen-tools:master Mar 11, 2024
@noirbizarre noirbizarre deleted the fix/git-parsing-lang branch March 11, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants