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: return unique repositories only #90

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/resolve-repositories.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ export async function resolveRepositories(state, repositories) {

process.stdout.write("\n");

// return unique array (https://www.samanthaming.com/tidbits/43-3-ways-to-remove-array-duplicates/)
return [...new Set(resolvedRepositories)];
// return array with unique repositories based by name (https://stackoverflow.com/a/56757215)
return resolvedRepositories.filter((repo, index, repoList) => repoList.findIndex(v2 => (v2.name === repo.name)) === index);
Copy link
Member Author

@stefanbuck stefanbuck Sep 29, 2022

Choose a reason for hiding this comment

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

I changed id to name to make the test passing. However, I think we should use eitherfull_name or id here to avoid situations where repo names are the same in different organisations. Doing so will result in a slightly bigger refactoring (mainly around tests) so wanted to discuss it first. What do you think @gr2m

Copy link
Member

@gr2m gr2m Sep 29, 2022

Choose a reason for hiding this comment

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

I'd definitely prefer to compare by id, can you do a follow up issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, no problem

}