-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
gem sources --prepend and --append allow finer grained control of sources
#8901
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
Conversation
176c651 to
244a162
Compare
|
This sounds good! I doubt usefulness of current Currently I've never seen private/custom sources used as a rubygems.org fallback, but the other way around. People want gems installed from their private sources, and their dependencies (if missing) fallback to being picked from rubygems.org. Should we deprecate |
|
I think the best solution would be to keep the That makes the interface clear and doesn't break any uses that we aren't imagining right now. If we want to add a deprecation now, we could fully remove in 4.0 or just leave it there as an alias for --append, which I don't think would cause any harm. I vaguely remember dealing with this problem in 2010ish. This has probably been the API as long as rubygems has existed so whatever the shortcomings of Edit: One argument for removing |
|
I'm inclined to merge this. If I'm not mistaken, we want |
|
Yeah, the only alternative I see would be to change A couple of things I noticed:
|
|
Oh, sorry, I missed your other PR. That makes sense to me since now there's a nice symmetry between |
|
Yeah, I do wonder if append is ever the right thing to do. I sort of doubt anyone uses the sources command in a serious way. |
|
Now I'm thinking about |
I think they are! |
|
I've been thinking about this and I think the most obvious declarative interface is: $ gem sources --first https://mysource.dev
Source added (or moved) to first position
$ gem sources --last https://rubygems.org
Source moved to last positionWith just the declarative, and short, first and last, we can imply both movement and addition. I also think that We can move the cache clearing to a more explicit |
|
Nope... I don't like I think the semantic confusion of "if it's already there, we're going to move it" is really not bad. We have three choices that I see for when the source is already added:
Between the choices, option 2 seems more desirable since it does what you asked: the source is now in the position requested without requiring prior knowledge of the order or contents. We can either be helpful and do it, or leave you in a weird state where you have to respond to the output and adjust. My specific use case is being able to blindly run this on dev machines where I don't know sources and state. I could be heavy handed and delete all sources and start completely fresh, but if sources move properly I can ensure that the private source is first and then not care about the rest of the contents. |
de0cdcf to
ceeb081
Compare
gem sources --prepend adds gem sources at the topgem sources --prepend and --append allow finer grained control of sources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to add --append and --prepend with semantics as implemented in this PR. But I'd keep --add as it is (and all of its tests) for now. Then deprecate it separately. Then eventually remove it on a major version.
ab35d49 to
d935557
Compare
--append adds a source to the end, moving it to the end if it already exists. --prepend adds or moves a source to the beginning. This allows idempotent sorting of gem sources without removing and adding.
d935557 to
d9a0567
Compare
|
Updated to make this only additive (besides a little refactoring) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
(cherry picked from commit 9b03374)
(cherry picked from commit 9b03374)
What was the end-user or developer problem that led to this PR?
I need a way to programmatically and idempotently add a source to the top of the sources list.
Previously, sources could only be appended using the
gem sources --addcommand since rubygems.org was always re-added as the first source when there were no other sources.What is your fix for the problem, implemented in this PR?
This improves the ability to add sources programmatically by enabling sources to be added in front of rubygems.org.
It also renames the primary command line options to
--appendand--prependand allows you to use the flag multiple times (in which case it behaves as if the command was called multiple time with each flag).One edgecase I didn't fix: if you
--appendand--prependthe same source, the order is indeterminate. I hope that's just not a thing people do, because fixing it seemed like unnecessary complexity.Make sure the following tasks are checked