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_packages by osp-project to cover non-url strings #172

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

amoralej
Copy link
Contributor

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.

Copy link
Contributor

@cescgina cescgina left a 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.
@sdatko
Copy link
Member

sdatko commented Feb 3, 2025

lgtm

we don't do that here 😛

/edit/ ach, sorry, I confused with /lgtm command from operators repos, nevermind 😅

@@ -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)
Copy link
Member

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)

Copy link
Member

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...

Copy link
Member

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

@sdatko sdatko left a comment

Choose a reason for hiding this comment

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

Good enough

@sdatko sdatko merged commit daa5191 into RedHatCRE:main Feb 4, 2025
1 check passed
@amoralej
Copy link
Contributor Author

amoralej commented Feb 4, 2025

Thanks!

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.

3 participants