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
Changes search index format to fasten pod search --full
command.
#4249
Changes search index format to fasten pod search --full
command.
#4249
Conversation
This is great! 🚀 Were you able to run the specs? There are two failures, reproduced here:
|
Yeah, I observed them also, but couldn't have time to fix it. Hoping to fix these tomorrow. |
That's great! 🚀 |
Hey @floere, I checked again and discovered that failures were caused by Core repo here not containing my changes in CocoaPods/Core#265. How should I manage this? This PR is tightly coupled to changes in Core repo, so I guess it will not pass unless the PR in Core repo is merged. Need suggestions. |
Are the Core changes standalone? (They work independently?) On Sun, Oct 4, 2015 at 3:09 PM, Muhammed Yavuz Nuzumlali
|
Core include changes on |
You can point the gem file here to your branch until the Core PR is merged |
@segiddins I tried your suggestion but probably missing something. Added the following line to Gemfile of CocoaPods project:
When I run rake spec I get the following error:
Is this default Core dependency come from |
Ah, got it. Removed cp_gem line for Core dependency. |
702c1ce
to
ebf5d8c
Compare
@floere, previous errors have gone now. However, there are two fails for functional specs. I was not observing them in the previous commit. I think they may be related to changes included from that time until now because I rebased the branch with master before sending the last commit. Also the failure seems not related to any source file that I've changed. |
ebf5d8c
to
cfd97e4
Compare
Hi, I've completed update index policy. All tests pass but got a strange error during running Inch.
What could be the reason? |
That happens when inch fails, so something isn't properly documented. |
@floere with the last commit all tests pass. You may check out them now. |
W00t! Excellent work, @manuyavuz , really look forward to reviewing this! If you want, feel free to give me your email so we can get you into our slack org? |
Thanks @segiddins! I would be very happy to join the slack team because I'm hoping to contribute more. You can use the email in my github profile. Waiting to hear for more! |
sources.each do |source| | ||
UI.section "Updating spec repo `#{source.name}`" do | ||
Dir.chdir(source.repo) do | ||
begin | ||
prev_commit_hash = (git! %w(rev-parse HEAD)).strip |
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.
can we move this updating logic into Source
? i.e. so it has an update
method that returns the changes spec paths?
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 mean moving also the following, right?
output = git! %w(pull --ff-only)
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.
yup!
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.
@segiddins should we also move UI code there into source?
I don't think it's suitable because we would need config object inside source to handle UI things.
I'm thinking of making a method returning a tuple variable including git pull output and changed paths. It would be sth like this:
output, changed_spec_paths = source.update
Does this fit?
Yup |
9bd70c7
to
868d911
Compare
def save_search_index(index) | ||
require 'json' | ||
@updated_search_index = index | ||
File.open(search_index_path, 'w') do |file| |
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.
search_index_path
should be a Pathname
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 think this way works too. Current implementation also performs open in the same way as the following:
File.open(search_index_path, 'w') do |file|
file.write(search_index.to_yaml)
end
What kind of problem may we face?
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.
No problem, we just try to stay away from using strings as paths and use pathnames instead
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 think it indeed gives a pathname. It's a method of sources_manager as the following (line 202):
# @return [Pathname] The path where the search index should be stored.
#
def search_index_path
Config.instance.search_index_file
end
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.
in that case, lets just use search_index_path.open
I've completed implementation and fixed multi word search issue. Solving that required a change in cocoapods-search plugin also (CocoaPods/cocoapods-search#10) I think this is ready for final review too. |
@segiddins Wouldn't original update method (therefore the |
Good point. I'd just expect that the background method get's called then, manually call the synchronous method, and then verify |
I actually did as you suggest in unit tests of SourcesManager class. However, not sure if this is an appropriate thing to do in a functional spec. Failed test is the following: it 'updates a repository' do
upstream = SpecHelper.temporary_directory + 'upstream'
FileUtils.cp_r(test_repo_path, upstream)
Dir.chdir(test_repo_path) do
`git remote add origin #{upstream}`
`git remote -v`
`git fetch -q`
`git branch --set-upstream-to=origin/master master`
end
lambda { command('repo', 'update').run }.should.not.raise
end Is it alright to change it like the following?: it 'updates a repository' do
upstream = SpecHelper.temporary_directory + 'upstream'
FileUtils.cp_r(test_repo_path, upstream)
Dir.chdir(test_repo_path) do
`git remote add origin #{upstream}`
`git remote -v`
`git fetch -q`
`git branch --set-upstream-to=origin/master master`
end
# Add expect for bg method
SourcesManager.expects(:update_search_index_if_needed_in_background).with({}).returns(nil)
lambda { command('repo', 'update').run }.should.not.raise
end If this is OK, I'll make a last rebase and push final version. |
IMHO that's fine |
- Previous implementation was having the drawback of traversing and performing `gsub` on all index strings for each pod specification. - New implementation stores words as keys and list of pods containing corresponding word inside their specification as the values for corresponding hash keys. Therefore, while searching for a query, we only need to check if query is matched with any key in index hash, if so, we will add corresponding list of spec names to a Set object. Resulted Set object gives us the search result. Using this policy, sources manager can perform a faster search operation.
- Override update_git_repo method of Source class in SourcesManager, and uses Executable instead of backticks. This provides streaming command output to STDOUT.
fa15c40
to
7cfdff8
Compare
5a5f96f
to
956ca76
Compare
956ca76
to
a7f504f
Compare
Offenses made me sick 😤 I think this is ready to 🚀 also. You can now make a last glance. |
SourcesManager.update(test_repo_path.basename.to_s, true) | ||
UI.output.should.match /is up to date/ | ||
end | ||
|
||
it 'uses the only fast forward git option' do |
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 test can come back
😄 super well done! |
👍 |
It appeared again 😉 |
🚀 🚢 |
Changes search index format to fasten `pod search --full` command.
Great! |
Detailed discussion can be found here: CocoaPods/cocoapods-search#8
gsub
on all index strings for each pod specification.