Skip to content

Add Unicode Support #629

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 10 commits into from
Aug 1, 2023
Merged

Conversation

adam-grant-hendry
Copy link
Contributor

@adam-grant-hendry adam-grant-hendry commented Dec 3, 2022

Adds unicode support by allowing configurable encodings to be specified (defaults to utf-8).

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

Fixes: Issue #516

@codecov
Copy link

codecov bot commented Dec 3, 2022

Codecov Report

Patch coverage: 98.02% and project coverage change: +0.02% 🎉

Comparison is base (eb39f8b) 97.31% compared to head (8ae25d0) 97.33%.
Report is 56 commits behind head on master.

❗ Current head 8ae25d0 differs from pull request most recent head ecc3365. Consider uploading reports for the commit ecc3365 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #629      +/-   ##
==========================================
+ Coverage   97.31%   97.33%   +0.02%     
==========================================
  Files          42       42              
  Lines        2045     2104      +59     
==========================================
+ Hits         1990     2048      +58     
- Misses         55       56       +1     
Flag Coverage Δ
unittests 97.33% <98.02%> (+0.02%) ⬆️

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

Files Changed Coverage Δ
commitizen/out.py 91.66% <50.00%> (-8.34%) ⬇️
commitizen/providers.py 97.52% <90.00%> (+0.22%) ⬆️
commitizen/commands/init.py 87.55% <95.23%> (+0.12%) ⬆️
commitizen/commands/bump.py 97.64% <96.66%> (-0.51%) ⬇️
commitizen/version_schemes.py 98.42% <98.42%> (ø)
commitizen/__version__.py 100.00% <100.00%> (ø)
commitizen/bump.py 100.00% <100.00%> (ø)
commitizen/changelog.py 99.50% <100.00%> (-0.50%) ⬇️
commitizen/changelog_parser.py 97.01% <100.00%> (+0.09%) ⬆️
commitizen/cli.py 94.20% <100.00%> (ø)
... and 17 more

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

@adam-grant-hendry
Copy link
Contributor Author

@Lee-W @woile Please review when you get a chance. Thanks!

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

@adam-grant-hendry Thanks for the update! Just one minor discussion needed on my side.

@woile I'm planning on merging this next week. Let me know if you need more time to take a deeper look. Thanks!

@woile
Copy link
Member

woile commented Dec 6, 2022

LGTM, the only thing missing is documentation: https://commitizen-tools.github.io/commitizen/config/

Ideally, I think the cz init should ask for the encoding if you are on windows, this would make windows users aware of potential encoding issues

@Lee-W
Copy link
Member

Lee-W commented Dec 9, 2022

It seems CI failed on windows 🤔

@adam-grant-hendry
Copy link
Contributor Author

@Lee-W I didn't push any commits yesterday, but it is showing that I did through Unverified commits. By chance, was this you?

@Lee-W
Copy link
Member

Lee-W commented Dec 31, 2022

Hi @adam-grant-hendry , yes I tried to rebase the master branch to this one to see if the latest update fix this branch

@woile
Copy link
Member

woile commented Apr 28, 2023

Is this still valid? Please rebase 🙏🏻

@adam-grant-hendry
Copy link
Contributor Author

@woile @Lee-W Apologies for taking so long: I've been away for quite some time. My gpg signature keys are outdated, but the commits are by me.

mypy is still unhappy with line 6 of out.py (See: python/typeshed#3049). I added a #type: ignore, but Python 3.7 reads this as an unused type ignore (See: https://github.com/commitizen-tools/commitizen/actions/runs/5491623964/jobs/10008334198#step:5:251), so I'm stuck.

Only remaining item is to add documentation. I added encoding as a keyword argument to changelog.py/get_metadata so as to not break backwards-compatibility with the added scheme argument.

@adam-grant-hendry adam-grant-hendry requested a review from woile July 10, 2023 18:30
@adam-grant-hendry
Copy link
Contributor Author

@woile @Lee-W Everything is good now. Could you please re-review the changes and make sure I added everything you requested?

@Lee-W
Copy link
Member

Lee-W commented Jul 11, 2023

@adam-grant-hendry Sure! I'll take a look these days.

@Lee-W Lee-W removed the os: Windows label Jul 11, 2023
@adam-grant-hendry
Copy link
Contributor Author

Hi @adam-grant-hendry , sorry for the late review. Overall the changes are good, but I think we should drop commit 3430edba7a5b1b4f59e5b7aa48e03bd15ccc32a4 and 9af6c748eb1084c5239e8d8058e7eddd59abbfb5 which downgrades the version of our GitHub actions workflow. Also, I notice some open and smart_open miss this encoding feature. Is this intentional? Or just accidentally missed? Thanks!

No worries at all. Thank you for your review!

  1. Yes, good find: we should definitely drop those commits then
  2. That was certainly an accidental miss on my part. I’ll review, make changes, and push up the fixes

I probably can’t get to this today, but I can start tomorrow. I’ll see if I can request your re-review by Monday morning.

Thanks again!

@adam-grant-hendry
Copy link
Contributor Author

@Lee-W I made all the changes discussed. Please re-review this PR at your earliest convenience. Thank you!

@Lee-W
Copy link
Member

Lee-W commented Jul 26, 2023

@adam-grant-hendry Sure! I'll try to take a look this weekend

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

Overall, I'm good with this PR. But we missed a few places missed. Wondering is it designed this way or just missed.

with open("pyproject.toml") as f:
,
with open("/dev/tty") as tty:
.

But, yep looks like they might be something not affected 🤔

I'm planning on merging this next week. @woile Please let me know if you want to take a deeper looks 🙂

@Lee-W
Copy link
Member

Lee-W commented Jul 29, 2023

@adam-grant-hendry ah, just notice a conflict. might need your help to resolve it.

@adam-grant-hendry
Copy link
Contributor Author

...But we missed a few places missed. Wondering is it designed this way or just missed.

with open("pyproject.toml") as f:

,

with open("/dev/tty") as tty:

.
But, yep looks like they might be something not affected 🤔

I purposefully left these out as I considered them "trivial" cases. By that I mean the "pyproject.toml" case is only looking for the "[tool.poetry]" table heading, which should generally not be affected by whether the file is opened in utf-8 mode or not. As for "/dev/tty", there is no equivalent to "/dev/tty" on Windows machines, so this would only run properly from a Linux environment, in which case the encoding is already utf-8 by default.

@Lee-W
Copy link
Member

Lee-W commented Jul 30, 2023

Sounds good 👍 Just want to confirm it. I think we're good to merge it after resolving the conflict. Thanks!

Copy link
Member

@woile woile left a comment

Choose a reason for hiding this comment

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

LGTM as well. Thanks!

@Lee-W Lee-W added the pr-status: ready-to-merge almost ready to merge. just keep it for a few days for others to check label Jul 30, 2023
This will allow commiting, e.g., emoji's and parsing commit messages for
unicode characters when creating change logs.
Also, use `utf-8` by default on Windows in `out.py`.
Map `"encoding"` and `"name"` to `encoding` and `name` variables, respectively (removes hard-coding of values).
Add `encoding` parameter to `open` and `smart_open` method calls where missed. Use `defaults.encoding` as default.
@adam-grant-hendry
Copy link
Contributor Author

@adam-grant-hendry ah, just notice a conflict. might need your help to resolve it.

I had to pull in the latest commits to master and rebase. It's all good to go now!

@Lee-W Lee-W merged commit df7acce into commitizen-tools:master Aug 1, 2023
@Lee-W
Copy link
Member

Lee-W commented Aug 1, 2023

Many thanks! Just merged

@adam-grant-hendry adam-grant-hendry deleted the feat/unicode branch August 1, 2023 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue-status: needs-triage pr-status: ready-to-merge almost ready to merge. just keep it for a few days for others to check pr-status: wait-for-modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants