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 naming of packages added to target koji tag #105

Merged
merged 2 commits into from
Mar 14, 2018

Conversation

khardix
Copy link
Collaborator

@khardix khardix commented Feb 21, 2018

KojiBuilder was incorrectly handling naming of metapackages when adding them to target tag, essentialy duplicated the collection name (i.e. adding rh-ror50-rh-ror50 in place of just rh-ror50).

This fix adds a check for the metapackage name, avoiding the duplication.

@khardix khardix added the bugfix label Feb 21, 2018
@khardix khardix self-assigned this Feb 21, 2018
collection=self.collection,
name=package_dict['name'],
))
if package_dict['name'] == self.collection: # metapackage
Copy link
Member

Choose a reason for hiding this comment

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

Make this a function. You can then test the function isolated without all the bloody mocking.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, bit of a brainf*rt on my part. I will take time to do this properly next week.

Thanks for keeping the technical debt at bay ☺ !

@khardix khardix force-pushed the fix/add-package-naming branch 2 times, most recently from de3ed20 to 22854c6 Compare February 28, 2018 10:20
@khardix
Copy link
Collaborator Author

khardix commented Feb 28, 2018

Next attempt at this fix. This time, I left it in two commits:

  1. The first one (c8ff0ca) contains the fix itself, extracted into separate function (as requested), with test and associated changes in related functions.
  2. The other one is refactoring (making regular methods from static ones, extracting repeated test setup into fixture, etc.).

"""

# The metapackage, or the base_name already has the prefix applied.
if base_name.startswith(collection):
Copy link
Member

Choose a reason for hiding this comment

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

Should it not start with colection+'-'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, because the name of the metapackage is exactly collection. base_name is not NVR, just the "N" part.

Copy link
Member

Choose a reason for hiding this comment

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

So in fact it should be: if base_name.startswith(collection + '-') or base_name == collection:?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically, yes. The important part is the base_name == collection. The startswith check is best-effort to avoid duplicate attachment of the prefix if the name already starts with it (and so in fact it is full_name).

If we are afraid of false positives here, I would drop the startswith check entirely.

Copy link
Member

Choose a reason for hiding this comment

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

I'm just being paranoid. However I was bit by almost the same thing in the past. See pytest-dev/pytest#2939 (comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I understand. The trouble here is that I'm not sure if the '-' at the end would help anyhow 😉.

Since the problem I'm trying to solve here manifests (so far) only on metapackages, I will drop the startswith check, which should make the condition unambiguous. It can be always added back if we run into a case that needs it.

Copy link
Member

Choose a reason for hiding this comment

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

Do it. Thank you.

-   Turn static methods for rebuild steps into regular ones
-   Extract mocking in tests into dedicated fixture
@khardix khardix merged commit 7b1924d into sclorg:master Mar 14, 2018
@khardix khardix deleted the fix/add-package-naming branch March 14, 2018 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants