-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[Installer] Add support for source provider plugin hook #3792
Conversation
class SourceProviderHooksContext | ||
# @return [Podfile] The Podfile for the project. | ||
# | ||
attr_accessor :podfile |
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 don't see why the sources would need access to the podfile?
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.
You are totally correct, I only included it because before I was using the Podfile as a way to insert my sources manually. With this plugin, it isn't needed.
I'd really love to see a test for this that actually uses a plugin source |
Hey @segiddins, thanks for the feedback! I have tested my own plugin which supports "local" sources (ex. "private" for ~/.cocoapods/repos/private) but I am unable to publish that code at the moment. That might change soon. I'll work on the changes you suggested |
I apologize for the numerous commits, I cannot get rubocop to run on my machine due to some weird issues with gemfiles so I don't know about violations until the travis build tells me. If anyone who has access would like to cancel those extra builds please do so! |
Ping @segiddins |
|
Yes, I have tried that and I get the following:
I have tried running Anyways, any comments on my changes? I was able to get a test in using the plugin API albeit a bit verbose as far as tests go |
ping @orta |
Hello! So, from my perspective this looks all good. It also seems a small enough change that I'd prefer it getting in with 0.38. Given that 0.38 already comes with plugin API changes. I'm going to leave it to either @kylef / @neonichu / @segiddins to do the actual merging however, as they understand the codebase significantly better than I do. |
I'd be more than happy to make a new PR will all of those extra commits squashed into one if that makes it easier / cleaner, I did a terrible job of passing the rubocop tests heh.. |
Sure, do it, feel free to close this one - or you can squash the commits, and do a force push 👍 |
Chose the second option! |
Great, consider yourself accomplished in your task. Someone will finish up the merge job. |
@@ -33,6 +33,7 @@ class Installer | |||
autoload :FileReferencesInstaller, 'cocoapods/installer/file_references_installer' | |||
autoload :PostInstallHooksContext, 'cocoapods/installer/post_install_hooks_context' | |||
autoload :PreInstallHooksContext, 'cocoapods/installer/pre_install_hooks_context' | |||
autoload :SourceProviderHooksContext, 'cocoapods/installer/source_provider_hooks_context' |
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.
please fix the alignment here
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.
Even without a space they will not be aligned.. Do you want me to rename it so it is shorter?
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.
Nope, probably the best thing to do is add a space to all the others so they're aligned again :)
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.
Oops, I'm an idiot, that's a way better idea. Just pushed that in
This seems good, but would like to also get @kylef to take a look at this. 👍 |
Code look fine, can you add a CHANGELOG entry @amorde? The main concern I have with this implementation is that this API doesn't allow consumers to decide the order of sources with plugins. The ordering of sources is important as it can determine which source a Pod may be used from. source 'https://github.com/CocoaPods/Specs'
source 'svn://foo'
source 'cvs://bar' Is different to: source 'svn://foo'
source 'https://github.com/CocoaPods/Specs'
source 'cvs://bar' |
Sure, just pushed up the changelog now. Regarding the order of sources, unless I am mistaken I believe changing the order of where you put the call to # This SVN source will be evaluated before the master repo
plugin 'cocoapods-repo-svn', {
:sources => [
'https://svn.myserver.com'
]
}
source 'https://github.com/CocoaPods/Specs.git This should work as expected, because the installer does a Edit: I'm wrong, ignore what I said about the ordering here |
I don't believe the order of |
Yeah, I just had that realization as well. I'm not sure how to fix that to be honest |
@amorde I don't think that's the case, because the hooks won't be ran until |
@segiddins @kylef You are both correct. If there is a way we can support ordering I would be more than willing to add it but I'm not sure how to do that as of right now. I feel that this would still be a valuable feature and we could add the ordering later, but I understand if you do not want to include it until it supports ordering |
It might make sense to make the invocation of plugins ordered, but that still wouldn't solve the issue of ordering between native sources and plugin sources |
We could do something like this: # in `Installer.resolve_dependencies`
context = run_source_provider_hooks
analyzer.sources.insert(0, *context.sources_before_builtin)
analyzer.sources.push(*context.sources_after_builtin) Then let the plugin decide the order, possibly allowing the user to provide a flag as to whether to put it before or after the builtin repos |
@kylef Any thoughts? I can implement some sort of source ordering, but I think this pull request has become a large enough discussion that it would be a good idea to discuss ordering elsewhere / in a separate issue |
It might just be acceptable enough to say that if you care enough to be using a plugin for a source provider, they should be of the highest priority so that providers / users don't have to add a weird index in their pod files / APIs. |
Yeah, I agree. If using a private source that requires a plugin to support, you probably want your source to come first. I will change the |
Sounds reasonable to me |
Just wondering if there's any info on this getting merged. We are looking to use this along with the |
What about executing the Example: plugin 'cocoapods-svn', :source => 'svn://foo'
source 'https://github.com/CocoaPods/Specs'
plugin 'cocoapods-cvs', :source => 'cvs://bar'
plugin 'cocoapods-svn', :source => 'svn://zzz' This way the user would get full control of ordering. |
That sounds perfect, but I don't see how that would be implemented. Right now any call to It seems that to implement that would require massive changes to the way the podfile is evaluated |
I think something that might be easier to implement would be to simply specify the master repo in the plugin's source, and let the plugin handle it (eg. just pass it off to the cocoapods implementation) plugin 'cocoapods-repo-svn', :sources => [
'svn://foo.com',
'https://github.com/CocoaPods/Specs',
'svn://bar.com'
] Then the plugin could do something like master = Pod::SourcesManager.master.first
if master.url == source_url
context.add_source(master)
else
# plugin source made here
end |
@kylef @segiddins I believe what I described above would allow the ordering of sources as long as plugins support the master repo, which is fairly easy. So if you're Podfile contained this: plugin 'cocoapods-repo-svn', :sources => [
'svn://foo.com',
'https://github.com/CocoaPods/Specs',
'svn://bar.com'
] It would behave as if you did this: source 'svn://foo.com',
source 'https://github.com/CocoaPods/Specs',
source 'svn://bar.com'
# There will be a duplicate master at the end, which should not matter
source 'https://github.com/CocoaPods/Specs', The time I am able to dedicate to this is wearing thin, so if a consensus cannot be reached I will have to abandon this, unfortunately. If there is anything I can do to make this work for you guys please let me know |
@kylef i agree with @amorde that supporting true ordering will likely require some pretty deep changes. i could maybe help with this if this is how we decide we need to do it. but i'm kinda in the same camp as @orta and feel that if you are far enough off the beaten path to use a source plugin then we can probably just resolve the source plugins in order before our regular source. and thanks so much @amorde for the time and effort you're putting into this! this is great stuff! |
+1 |
I feel like this is OK as is. |
I'm waiting for @kylef to review before merging, since he stated he had objections before |
It sounds good! |
@@ -22,6 +22,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` | |||
is now a default plugin. | |||
[Samuel Giddins](https://github.com/segiddins) | |||
|
|||
* Added a `:source_provider` hook to allow plugins to provide their own 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.
This should be moved to go under master, not beta 2.
Other than that one comment about CHANGELOG. This is good to go. |
I hope the
I think the |
I'm having a difficult time including the upstream changes to the changelog.. could anyone help me out? It appears I've introduced a merge conflict |
@amorde just reset |
Think I got it! |
[Installer] Add support for source provider plugin hook
Thanks for your contribution @amorde. |
In my case, it is printed the error message.
If I insert below lines then, printed above error messages.
Dont' mind about svn url. Anything cannot be worked. |
Changes Unknown when pulling fd2773d on amorde:master into ** on CocoaPods:master**. |
This PR provides an initial/example implementation for the source provider plugin api described in #3190
I very much welcome suggestions for improvements - still new to both Ruby and the CocoaPods code base so it is very likely I am missing something.
The API would allow plugins to supply their own sources, whether they be un-versioned or using an unsupported VCS such as CVS, Hg, SVN, etc.
Example: