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(datasource/galaxy): support multiple results #29664

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

Conversation

rarkins
Copy link
Collaborator

@rarkins rarkins commented Jun 13, 2024

Changes

Context

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@rarkins rarkins requested a review from secustor June 13, 2024 20:11
@rarkins rarkins enabled auto-merge June 13, 2024 20:11
`Received multiple results from ${galaxyAPIUrl}`,
);
return null;
const githubUsernames = body.results.map((result) => result.github_user);
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 filter here and warn if the filtered result is empty. that way we only have to iterate once.

lib/modules/datasource/galaxy/index.spec.ts Outdated Show resolved Hide resolved
lib/modules/datasource/galaxy/index.spec.ts Outdated Show resolved Hide resolved
@@ -50,13 +50,19 @@ export class GalaxyDatasource extends Datasource {
throw this.handleGenericErrors(err);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
body.results = body.results.filter((result) => result.github_user === username)

Comment on lines +54 to +65
const githubUsernames = body.results.map((result) => result.github_user);
if (githubUsernames.includes(userName)) {
body.results = body.results.filter(
(result) => result.github_user === userName,
);
} else {
logger.warn(
{ dependency: packageName, githubUsernames },
`Multiple results from galaxy for ${packageName}, none match`,
);
return null;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const githubUsernames = body.results.map((result) => result.github_user);
if (githubUsernames.includes(userName)) {
body.results = body.results.filter(
(result) => result.github_user === userName,
);
} else {
logger.warn(
{ dependency: packageName, githubUsernames },
`Multiple results from galaxy for ${packageName}, none match`,
);
return null;
}
logger.warn(
{ dependency: packageName },
`Received multiple results from ${galaxyAPIUrl}`,
);
return null;

Co-authored-by: Sebastian Poxhofer <[email protected]>
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