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

Don't repeat dependency names in PR title #5915

Merged
merged 3 commits into from
Oct 24, 2022
Merged

Conversation

mctofu
Copy link
Contributor

@mctofu mctofu commented Oct 18, 2022

This improves the PR title to only mention a dependency once if it's being updated to multiple versions.

ex: #5880

Fix #5888

@mctofu mctofu marked this pull request as ready for review October 18, 2022 18:44
@mctofu mctofu requested a review from a team as a code owner October 18, 2022 18:44
end
end

context "with two dependencies with the same name" do
let(:dependencies) { [dependency, dependency] }
Copy link
Member

@Nishnha Nishnha Oct 19, 2022

Choose a reason for hiding this comment

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

Maybe we should test this with 2 different dependencies (dependency and dependency2) with the same name and different versions?
That way we can be sure the versions are listed correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you thinking we should add a test for the PR body? This is only checking the title where we won't show the versions if theres more than one dependency before deduping.

I do like the idea of using different versions in this test case! That way we'll test that it's deduping just by name instead of the entire dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I improved the test case to have different version of the same named dependency in 3ee451b

Copy link
Member

@Nishnha Nishnha left a comment

Choose a reason for hiding this comment

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

Generally this looks good to me. I left one comment on a test case but the code change itself looks fine.

Comment on lines +82 to +86
if names.count == 1
"requirements for #{names.first}"
else
"requirements for #{names[0..-2].join(', ')} and #{names[-1]}"
end
Copy link
Member

Choose a reason for hiding this comment

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

💡 Since we have ActiveSupport available, we could use #to_sentence for this case (docs)

Copy link
Contributor

Choose a reason for hiding this comment

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

I had this change stashed so I just pushed it up here in case you want to use any of it: ce8eb68

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions! #to_sentence looks ideal but because it requires adding some new active_support imports I think it'd be better to make that change as a separate PR focused on adding active_support to simplify this class.

Comment on lines +113 to +117
if names.count == 1
names.first
else
"#{names[0..-2].join(', ')} and #{names[-1]}"
end
Copy link
Member

Choose a reason for hiding this comment

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

Same thought here re: #to_sentence 🙂

We expect this to happen when there are multiple versions of the same
dependency.
@mctofu mctofu force-pushed the mctofu/dedupe-dep-names branch from 3ee451b to 126dd42 Compare October 24, 2022 22:45
@mctofu
Copy link
Contributor Author

mctofu commented Oct 24, 2022

This is what the example PR looks like now:
image

We could do some additional de-duping at the start of the description but I'll leave that for a future PR.

@mctofu mctofu merged commit 6190c8a into main Oct 24, 2022
@mctofu mctofu deleted the mctofu/dedupe-dep-names branch October 24, 2022 23:37
@pavera pavera mentioned this pull request Oct 31, 2022
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.

PR title repeats dependency name
4 participants