question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature/refactor] Use named capture group in bump_pattern to enable stricter check

See original GitHub issue

Goal make regular expression pattern stricter so that we won’t accidentally match things we don’t need

Description In commitizen/cz/conventional_commits/conventional_commits.py#L33 on command-changelog branch, I use named capture group so that we could use a stricter regular expression like .*\n\nBREAKING CHANGE. The benefit of it is that we don’t have to break the whole commit message into lines like commitizem/bump.py#L31. It can also avoid bump or generate changelog based on commit message like fix --- it does not follow the rule but still match the pattern. Another thought on this topic is that we probably merge the bump_map and bump_pattern into one some data class to store name(e.g., break), pattern(e.g., .*\n\nBREAKING CHANGE), behavior(e.g., PATCH).

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Lee-Wcommented, Jun 27, 2020

Still I see some complications, for conventional commits how would you capture BREAKING CHANGE and ! as breaking chagnes with a named group? I’ve tried a while ago with little success haha

Things like (?P<MAJOR>^.*\n\nBREAKING[-]CHANGE.*|)|(?P<MINOR>^feat.*), but not yet testesd.

Regarding the dataclasses I’d need an example to understand it better, for me a dict is usually clearer than anything, and can be easily converted to configuration if it’s kept simple.

I’m working on this refactoring in #203 . (I’ve not yet get to the dataclass part.) IMO, dataclass is a stricter solution and less error-prone. It explicitly indicates the type of each configuration. I’ll give you an example once I implement a prototype

0reactions
Lee-Wcommented, Jun 28, 2020

It seems we do not need to parse the message when we bump the project version. All we want to know is which version (i.e. MAJOR, MINOR, PATCH) to bump. What we need to know if whether these types (e.g., MAJOR, MINOR, PATCH) of commits exist.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Regex Tutorial - Named Capturing Groups - Backreference ...
Python's re module was the first to offer a solution: named capturing groups and named backreferences. (?P<name>group) captures the match of group into...
Read more >
How to capture text on either side of a pattern into a named ...
In Perl, a backreference matches the text captured by the leftmost group in the regex with that name that matched something... So in...
Read more >
Regex Capture Groups and Back-References - RexEgg
Yes, capture groups and back-references are easy and fun. But when it comes to numbering and naming, there are a few details you...
Read more >
Groups and backreferences - JavaScript - MDN Web Docs
Groups group multiple patterns as a whole, and capturing groups provide extra submatch information when using a regular expression pattern ...
Read more >
ES2018: RegExp named capture groups - 2ality
Numbered capture groups enable you to take apart a string with a regular expression. Successfully matching a regular expression against a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found