Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support version retrieval from custom branches #253

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 6 commits into from
Jun 9, 2018

Conversation

webknjaz
Copy link
Contributor

Fixes #251

return tuple(map(int, re.match(r'^.*(?P<version>\d+(\.\d+)+).*$', branch).groupdict()['version'].split('.')))
except AttributeError as attr_err:
raise ValueError(f'Branch {branch} seems to not have a version in its name.') from attr_err

return sorted(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Mariatta optionally we could try/except this as well and fall back to returning branches list in their original order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Mariatta what do you think about falling back to unordered branch list?

Copy link
Member

Choose a reason for hiding this comment

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

Since there is no need to support unordered branch list yet, I'm thinking to keep things as is and not change the behavior.

@@ -72,10 +73,16 @@ def upstream(self):

@property
def sorted_branches(self):
def version_from_branch(branch):
try:
return tuple(map(int, re.match(r'^.*(?P<version>\d+(\.\d+)+).*$', branch).groupdict()['version'].split('.')))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe reading regex template from config is even better?

Copy link
Contributor Author

@webknjaz webknjaz May 28, 2018

Choose a reason for hiding this comment

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

I see how it's more flexible. I was thinking about this, but IRL regex is easy to screw up: they'll be exposed to the internals and helpless, and it would require them to actually scan through the code to figure out how it's being used, why and how to fix that.
It also looks like mixing up higher-level public API with implementation details, which IMHO should be separated.
So I'd be cautious when providing the end-users with such tooling.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe invite a syntax like stable-* where the star is version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to be more complex than needed

@webknjaz
Copy link
Contributor Author

webknjaz commented Jun 4, 2018

@Mariatta I'm trying to add this to our workflow and this change would really help to adopt the tool. Would you mind taking a look at it, please?

@Mariatta
Copy link
Member

Mariatta commented Jun 4, 2018

Sorry for the delay @webknjaz. I intend to review your PRs sometime this week for sure.

@webknjaz
Copy link
Contributor Author

webknjaz commented Jun 4, 2018

Thanks!

Copy link
Member

@Mariatta Mariatta left a comment

Choose a reason for hiding this comment

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

Thanks @webknjaz. I think the changes look fine. Can you update the readme with info about what branch patterns are considered valid?

@webknjaz
Copy link
Contributor Author

webknjaz commented Jun 9, 2018

Sure, done!

@webknjaz webknjaz force-pushed the feature/support-other-branch-names branch from b2ac064 to 3209061 Compare June 9, 2018 09:13
@Mariatta
Copy link
Member

Mariatta commented Jun 9, 2018

Thanks! I made some changes to readme, but the rest looks great. Thanks for working on this ๐ŸŒฎ

@Mariatta Mariatta merged commit c1e26f9 into python:master Jun 9, 2018
@webknjaz
Copy link
Contributor Author

@Mariatta thanks! Please let me know when it's on PYPI.

P.S. If you would like it โ€” I can help with automation of release process of dists from Travis CI to PYPI, triggered by pushing tag, for example. Ping me if you're interested ๐Ÿ˜‰

@Mariatta
Copy link
Member

P.S. If you would like it โ€” I can help with automation of release process of dists from Travis CI to PYPI, triggered by pushing tag, for example. Ping me if you're interested ๐Ÿ˜‰

๐Ÿ˜ฒ I'm interested. See related issue #222 ๐Ÿ˜„
If you can propose the PR, I'll check it out.

@Mariatta
Copy link
Member

@webknjaz released to PyPI ๐ŸŒฎ

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.

4 participants