-
Notifications
You must be signed in to change notification settings - Fork 12
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_packages by osp-project to cover non-url strings #172
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Currently, the urlparse lib is used to find the short repo name from the osp-patches string in distroinfo. This does not work for non-url based strings as `git@gitlab.com:eng/test/repo_name.git`. This patch is moving to use regex instead of urlparse asuming that the repo name is the string after the last `/` and removing the `.git` if exists. This should cover all kind of strings that may be used in osp-patches field. Note this is changing slightly the behavior for repos in namespaces. i.e. before this patch if osp-patches is `ssh://server.com/foo/bar`, osp-project would be `foo/bar`. After this patch, it is `bar`. This behavior matches the current usage of this parameter which is used to matcht zuul.project.short_name which points always to the last part, `bar` in the previous case. This has not been affecting in the past because the osp-patches used were not namespaced.
we don't do that here 😛 /edit/ ach, sorry, I confused with /lgtm command from operators repos, nevermind 😅 |
znoyder/browser.py
Outdated
@@ -72,7 +74,10 @@ def get_packages(**kwargs): | |||
if kwargs.get('upstream') in str(package.get('upstream'))] | |||
|
|||
for package in packages: | |||
package['osp-project'] = urlparse(package['osp-patches']).path[1:] | |||
if package['osp-patches']: | |||
repo_name = re.search(r'^(.*)\/(.*)$', package['osp-patches']).group(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pep8: commands[0]> flake8
./znoyder/browser.py:78:80: E501 line too long (83 > 79 characters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it is under conditional? This may change the original behavior – the osp-project shall be always defined, based on osp-patches, so if we have no osp-patches we probably have some issues in ospinfo...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed directly here to move forward with blocked work
Fixed the line to long linter error and replaced the regex replace with non-regex solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good enough
Thanks! |
Currently, the urlparse lib is used to find the short repo name from the osp-patches string in distroinfo. This does not work for non-url based strings as
git@gitlab.com:eng/test/repo_name.git
.This patch is moving to use regex instead of urlparse asuming that the repo name is the string after the last
/
and removing the.git
if exists. This should cover all kind of strings that may be used in osp-patches field.Note this is changing slightly the behavior for repos in namespaces. i.e. before this patch if osp-patches is
ssh://server.com/foo/bar
, osp-project would befoo/bar
. After this patch, it isbar
. This behavior matches the current usage of this parameter which is used to matcht zuul.project.short_name which points always to the last part,bar
in the previous case. This has not been affecting in the past because the osp-patches used were not namespaced.