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

Warn if lib32- variant is missing when adding a group #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jelly
Copy link
Member

@jelly jelly commented Jun 11, 2018

When adding a new group, warn if the lib32 variant does not exists via a
flashcard.

Closes: #120

When adding a new group, warn if the lib32 variant does not exists via a
flashcard.

Closes: archlinux#120
@jelly jelly requested a review from anthraxx June 11, 2018 20:01
@jelly
Copy link
Member Author

jelly commented Jun 12, 2018

Do we want to consider adding a link the flash message to directly create a new AVG.

if not Package.query.filter(Package.name == lib32pkg).first():
continue

if CVEGroupPackage.query.filter(CVEGroupPackage.pkgname == lib32pkg, CVEGroupPackage.group == group).first():
Copy link
Member

Choose a reason for hiding this comment

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

can we make this algorithm in a way that we need to issue the queries once for all matches and not in a loop? optimally it looks like a single query can retreive all information we need to iterate over

Copy link
Member Author

Choose a reason for hiding this comment

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

I've just realized that we are creating the group here, so we don't really have to query the db! We can just query group.packages and check if it contains a lib32 package, we only need to verify if a variant exists in the repo however.

@@ -199,4 +200,21 @@ def add_group():

db.session.commit()
flash('Added {}'.format(group.name))
missing_lib32_variant(pkgnames, group)
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't quite say what it does, either we have a get_missing... and loop+flash here or we name it like flash_missing... or such. missing_lib32_variant itself doesn't say much what it actually does.


@create_package(name='foo', version='1.2.3-4')
@logged_in
def test_add_group_mising_lib32_invalid(db, client):
Copy link
Member

Choose a reason for hiding this comment

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

:%s/mising/missing/g

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@create_package(name='foo', version='1.2.3-4')
@create_package(name='lib32-foo', version='1.2.3-4')
@logged_in
def test_add_group_mising_lib32(db, client):
Copy link
Member

Choose a reason for hiding this comment

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

:%s/mising/missing/g

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -248,6 +248,37 @@ def test_add_group_with_dot_in_pkgrel(db, client):
set_and_assert_group_data(db, client, url_for('tracker.add_group'), affected='1.2-3.4')


Copy link
Member

Choose a reason for hiding this comment

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

i would love to see a test as well that already has the lib32 variant and adds the non-lib32 one later. maybe that case should be detected and flashed as well 😺

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, but the code is rather deeply nested, maybe some lambda/filter/map logic can be used to make it nicer.

@anthraxx anthraxx added this to the 0.9 milestone Jun 18, 2018
SantiagoTorres
SantiagoTorres previously approved these changes Jun 21, 2018
Copy link
Collaborator

@SantiagoTorres SantiagoTorres left a comment

Choose a reason for hiding this comment

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

other than this minor nit, and the current comments. LGTM



def missing_lib32_variant(pkgnames, group):
for pkgname in pkgnames:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I tested this locally and the behavior is correct. I wanted to make sure that we don't add a "there's a lib32 package added but this still flashes the warning" behavior. Could we add a test for it?

Copy link
Member Author

@jelly jelly Jun 23, 2018

Choose a reason for hiding this comment

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

Good idea! I think test_add_group_missing_lib32_invaid handles this case, since the lib32-foo pakage is not created.

Check if lib32-curl misses curl and if adding curl misses lib32-curl.
@SantiagoTorres
Copy link
Collaborator

This is a year old. Do we want to pick this up, @jelly ?

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.

Warn if a lib32-$package exists and no open AVG exists
3 participants