Skip to content

Add Unicode Support - #629

Merged
Lee-W merged 10 commits into
commitizen-tools:masterfrom
adam-grant-hendry:feat/unicode
Aug 1, 2023
Merged

Add Unicode Support#629
Lee-W merged 10 commits into
commitizen-tools:masterfrom
adam-grant-hendry:feat/unicode

Conversation

@adam-grant-hendry

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

Copy link
Copy Markdown
Contributor

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

codecovBot commented Dec 3, 2022

Copy link
Copy Markdown

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 
FlagCoverage Δ
unittests97.33% <98.02%> (+0.02%)⬆️

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

Files ChangedCoverage Δ
commitizen/out.py91.66% <50.00%> (-8.34%)⬇️
commitizen/providers.py97.52% <90.00%> (+0.22%)⬆️
commitizen/commands/init.py87.55% <95.23%> (+0.12%)⬆️
commitizen/commands/bump.py97.64% <96.66%> (-0.51%)⬇️
commitizen/version_schemes.py98.42% <98.42%> (ø)
commitizen/__version__.py100.00% <100.00%> (ø)
commitizen/bump.py100.00% <100.00%> (ø)
commitizen/changelog.py99.50% <100.00%> (-0.50%)⬇️
commitizen/changelog_parser.py97.01% <100.00%> (+0.09%)⬆️
commitizen/cli.py94.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
Copy Markdown
ContributorAuthor

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

@Lee-WLee-W left a comment

Copy link
Copy Markdown
Member

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!

Comment thread.github/workflows/pythonpackage.yml
Comment threadcommitizen/config/json_config.py Outdated
Comment threadcommitizen/defaults.py
Comment threadcommitizen/defaults.py Outdated
@woile

woile commented Dec 6, 2022

Copy link
Copy Markdown
Member

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

Lee-W commented Dec 9, 2022

Copy link
Copy Markdown
Member

It seems CI failed on windows 🤔

@adam-grant-hendry

Copy link
Copy Markdown
ContributorAuthor

@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
Copy Markdown
Member

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
Copy Markdown
Member

Is this still valid? Please rebase 🙏🏻

@adam-grant-hendry

Copy link
Copy Markdown
ContributorAuthor

@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

Copy link
Copy Markdown
ContributorAuthor

@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
Copy Markdown
Member

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

@adam-grant-hendry

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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

@Lee-W

Copy link
Copy Markdown
Member

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

@Lee-WLee-W left a comment

Copy link
Copy Markdown
Member

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.

withopen("pyproject.toml") asf:
,
withopen("/dev/tty") astty:
.

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 🙂

Comment threadcommitizen/bump.py Outdated
@Lee-W

Copy link
Copy Markdown
Member

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

@adam-grant-hendry

Copy link
Copy Markdown
ContributorAuthor

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

withopen("pyproject.toml") asf:

,

withopen("/dev/tty") astty:

.
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
Copy Markdown
Member

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

@woilewoile left a comment

Copy link
Copy Markdown
Member

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-WLee-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
Copy Markdown
ContributorAuthor

@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:masterAug 1, 2023
@Lee-W

Lee-W commented Aug 1, 2023

Copy link
Copy Markdown
Member

Many thanks! Just merged

@adam-grant-hendry
adam-grant-hendry deleted the feat/unicode branch August 1, 2023 15:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

issue-status: needs-triagepr-status: ready-to-mergealmost ready to merge. just keep it for a few days for others to checkpr-status: wait-for-modification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@adam-grant-hendry@woile@Lee-W