112 comments

[ 2.9 ms ] story [ 178 ms ] thread
I am crying tears of joy right now. Just. So happy.
This is a great enhancement. It's been a problem finding quality repos on Github as one of the key indicators for me was the "freshness" or time since last commit. The previous interface did not make this easy to evaluate but it looks like this new search has enough options to make my searching actually useful.
Now someone only needs to integrate this with the Facebook social graph search.
"People who like ruby and python and have write access in the php organization repositories"
Just took it for a spin. The implementation is fantastic.

Bravo, Github!

I'll be really pleased if this works in a usable manner, I'd very much given up on search in github.
It seems better than usable. It's quite good.
Are there any plans to make this available through the API?
+1 I'm anxiously awaiting the answer to this question too.
Yes. There will be a blog post when API access is available.
Nice one! Elasticsearch is great software for that purpose. I guess github's cluster is one of the bigger one out there now...
It is ironic since one of the Github's latest changes broke plugin distribution for ElasticSearch.
Github's just been killing it lately. Great start to the year.
Thank goodness. This is the part of GitHub that has been driving me up the wall for months. Google is pretty useless in this area when you're looking for something buried within a repo.

Fantastic job, it works beautifully. Congratulations (to GitHub and to Elastic Search - I'm sure it's a big win for them too!)

Nice. There are six C++ projects that use bool_t type.
And two (one of which has two additional forks) C projects that reference <stdbool.h>. Sadness!
Where is the link to the search page? When I go to github.com and it displays my dashboard, I can't find anything resembling a link to the search page. There's the command bar, but it doesn't seem to provide code search unless you click the advanced search link. I love the new features Github has developed over time, but if it's a pain to find the feature, it's not going to see a lot of use.
Its pretty neat now. They forgot the "I'm feeling lucky" button though.
When I try the advanced search with "something stars:>500" it also seems to match the string "500" in code for some reason.

Edit: And apparently "stars" for that matter.

Being able to filter by stars is great...One other filter that would be nice is days-since-lsat-commit. I guess number of stars is rough estimate of how active a repo is, but as the years go on, there will probably be more and more projects that are basically dead, yet still have a high number of stars.
Filters and sorting are definitely next on our priority. We will do another blog post when that happens.
very nice. one bad setting (perhaps a default that never got overridden) is that searching for foo_bar searches for foo and bar separately, rather than treating foo_bar as an indivisible token.
Just search for '"foo_bar"' rather than 'foo_bar'.
i know, but in the context of code search foo_bar is almost always a single token, since the underscore is nigh-universally used in variable and function names.
Is there an "order by" functionality? When looking for code. I like to find the code with the most stars.

Ugh.. that reminds me of the good old days when HN had visible karma points...

This is awesome, but I'm a little confused about the treatment of underscores. If you search for something like "secret_key" (teehee) it will return results for just 'secret' and just 'key' seemingly :-\ Not what I expect out of code search, but easy enough to fix if it's deemed a bug.
Surround in quotes and it won't split on the underscore.
It looks like I jumped the gun. The search itself seems fine, but the highlighter is a bit overzealous
Is it me or does is seem like every day either Github or Stripe shipping some sweet new feature?

I need to read less and code more.

It's probably the fact that they ship a lot and HN is non-platonically in love with both so new features get a lot of attention.
> To ensure better relevancy, we're being conservative in what we add to the search index. Repository forks will not be searchable unless the fork has more stars than the parent repository, for example.

This has a grandfathering problem when the maintainers switch. The new active branch of development is overshadowed by the previous branch. I've had someone takeover my project, but I still have 2 years of accumulated stars from when the project was fresh. The new development has less than 1/10 the number of stars as my branch. But I guess fixing this is kind corner case might be left for v2.

Have you considered renaming your fork? Like xyz-old? One of the things that annoys (and sometimes infuriates) me about github is identifying the fork I want to be using. A million old blog posts point to the wrong place. If that repo were replaced with a new blank repo saying "moved to here" it'd be a big help.
I did change the readme to point to the new mainline development. I still think there might be some utility in having the code as I left it around, so I didn't delete the repo.
Deleting your repo and recreating it as a fork of the new upstream may be a good idea, although it does break the links to all of the other repositories forked from yours. It really would be nice if Github handled this case better.
Deleting and recreating your repo isn't necessary. If there's a problem with your fork not showing up, let us know and we'll look into it.
Didn't you transfer the ownership of repository ?
I just updated a userscript I created a while back so it works with the new code search: https://github.com/skratchdot/github-code-search.user.js/

It's just a shortcut for searching the current repository you are viewing (by adding a search box next to the tag count).

Your script would be awesome, something I don't understand why Github doesn't provide natively. Unfortunately it isn't working for me that well.

Go to one of my org's repos: http://github.com/railsforcharity/spokenvote

and search this string (which is in our seeds.rb): users << User.create({name: 'Voter1', email: 'voter1@example.com', password: 'abc123', password_confirmation: 'abc123'})

I not only don't get the right result, I don't get any text in the search results area of the page, not even a nothing found message. Same thing if I do the search on my personal fork.

Sorry for the delay. I was at work so couldn't respond right away.

All the userscript does is proxy the advanced search results page, so the search you tried hits this page:

https://github.com/search?type=Code&q=users+%3C%3C+User....

If you only search for voter1@example.com, results are shown:

https://github.com/search?type=Code&q=voter1%40example.c...

Anyways, you did find a "0 results" bug which should now be fixed. Thanks for that!

Glad to point out someone else's mistake for a change ;)
This is awesome. Searching GitHub code has been my way of learning idioms or seeing how others have solved a similar problem. This will make it much easier.