Skip to content
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

Fix get_loader().load() from local couldn't get version correctly #59

Merged
merged 8 commits into from
Oct 24, 2019

Conversation

JayZ12138
Copy link
Contributor

When version is None, it wrongly tries to get version from filename instead of the file path.

ubiconfig/_impl/loaders/local.py Outdated Show resolved Hide resolved
# ubi7.1.
version = os.path.basename(os.path.dirname(os.path.abspath(file_path)))

if not re.search(r"ubi[0-9]{1}\.?[0-9]{0,2}$", version):
Copy link
Member

Choose a reason for hiding this comment

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

hmm,
are you sure of this? It makes only dot optional.
Shouldn't it be:
ubi[0-9]{1}(\.[0-9]{0,2})?

Copy link
Contributor Author

@JayZ12138 JayZ12138 Oct 24, 2019

Choose a reason for hiding this comment

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

Hm, it should be r"ubi[0-9].[0-9]{1,2}$|ubi[0-9]$"

Copy link
Member

Choose a reason for hiding this comment

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

what is allowed?
ubi7
ubi8
ubi7.1
ubi8.9
ubi7.10

I guess my regex would do the trick.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if ubi[0-9]{1}(.[0-9]{0,2}) is your last version, but if you do:

re.search(r'ubi[0-9]{1}(.[0-9]{0,2})', 'ubi8')

If I change it to 'ubi[0-9]{1}(.[0-9]){0,3}':

re.search(r'ubi[0-9]{1}(.[0-9]){0,3}', 'ubi710')
<_sre.SRE_Match object at 0x7f79f1819558> # shouldn't match.

Copy link
Member

Choose a reason for hiding this comment

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

@JayZ12138
next time let's code formatter in comment, otherwise it can strip out some chars

I was wrong before:
the shortest correct should be:
r'ubi[0-9](\.[0-9]{1,2})?$'

@JayZ12138 JayZ12138 merged commit 5135163 into release-engineering:master Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants