Hello everyone, dear friends! As a lover of new features on GitHub, it was very interesting for me to know that soon we will all be able to quickly and efficiently search the GitHub codebase. This can be very handy, especially if you need to find a sophisticated way to use a tool. This especially resonates with the fact that a future competitor to GitHub has been opened in Russia. Therefore, GitHub is definitely not worth resting on its laurels, despite the fact that they are undoubtedly market leaders. We need to go further and develop, otherwise the hour is not even and competitors will catch up and sweep away. And don't let it seem so unbelievable. As an example: how many people still use Nokia phones? Who even knows they made phones? At one time they were simply unattainable, undisputed market leaders ... And now they appear somewhere in the field of statistical error.
First impression
GitHub has created a project where you can search, navigate, and analyze your code and the billion lines of code published on GitHub. It is important to note that the search is scalable, fast and accurate. It was created from scratch specifically for code search. Navigation works for 10 major programming languages without customization (we hope that the list will grow in the future). You can search by regular expression, which is very cool. Other filters are also available:- by organizations;
- programming languages;
- by specific owner;
- by file extension
- by regular expression.
Let's talk in more detail about the search
It is very interesting to look in and try to search for yourself: is it as convenient as they say? So far, this feature is not in the public domain and you can add yourself to the waiting list using the link . There we fill in all the points, the questions are simple, I will not describe here. As a result, we are added to the waiting list and move on. As a result, there will be such an answer: It remains just to wait. As soon as they add me, I will definitely show you everything. Do not delay, add yourself so that later you can figure it out in the forefront and use it for your own joy) And of course it’s a pity that you can’t immediately try out a new tool, so we’ll analyze their documentation and describe in more detail how we can use this tool for our work. Now about the search. In it I will use classes and constructions that make sense inlibrary that I write. This will make it clearer and easier for me, and I hope you will too.Basic search
ImageComparison is the simplest search that searches exactly as requested in filenames and their contents. Everything here seems very simple. If we want to find clearly by the name of the class, where it is declared and where it is used, such a search will help us with this. When you enter multiple words separated by spaces, the result will be a search for all separately: Image Comparison , that is, it will find files and code for both Image and Comparison . If you need to search for some string containing spaces, then you just need to use quotes for this. For example: “ImageComparison comparison = new ImageComparison()”and then the search will go to match the entire string. For escaping, we use “\” as always. So far, everything is intuitive and often done that way. Further, we can add filters to this basic search. So let's talk about each of them. These will be logical “ANDs” to the filter we have already created.Filter by repository
When our basic filter is ready, we can narrow down the search and search for a specific repository, which is very convenient. You don't need to look for what folder the class is in, you can just write:
repo:romankh3/image-comparison ImageComparisonResult
Where we need to specify repo:${user_name}/${repo_name} . You can also search across multiple repositories by simply adding OR:
repo:romankh3/image-comparison OR repo:romankh3/usage-image-comparison ImageComparisonResult
As stated on GitHub, at the moment they do not support searching through repositories where the name is specified as a regular expression ... And this means that they plan to add such an opportunity and means that the project will not stop at the declared functionality and will develop further.
Filter by organization
Searching for an organization or user is done in the same way as searching for a repository, only the keyword will not be repo , but org :
org:romankh3 ImageComparison
And then the search will go through all the repositories of the user / organization.
Filter by programming languages
You can also specify a search for files in a specific programming language. Here the construction is the same as for the repository and organization, only the key word is language :
language:java ImageComparison
Just like for the repository, it supports searching in several languages at once using the OR keyword:
language:java OR language:ruby ImageComparison
The full list of languages supported by GitHub can be found here . I wonder if BrainFuck is there? 😂
Filter by file path
Each file in the project has its own path and can also be searched by adding a filter. For example, there is an ImageComparisonResult file , it has a path:
src/main/java/com/github/romankh3/image/comparison/model/ImageComparisonResult.java
So, to find all classes whose path starts with src/main/java/com/github/romankh3/image , you need:
path:src/main/java/com/github/romankh3/image
Can be useful when we don't want test classes to be excluded from our search. Or vice versa, just tests. This makes the search more flexible. The file path filter can be specified using a regular expression. For example, we need to find
path:src/*/*.js
Boolean operations
And, of course, the culmination of all filter building is bringing it all together with Boolean operations. For this we have AND, OR, AND NOT. I think this should be enough for us. For example, let's make a complex search query: Java or Kotlin production code from a specific user/organization:
repo:romankh3 AND (language:java OR language:kotlin) AND NOT path:*/test/*
And let me tell you, it's just incredible. So simple, fast, concise and understandable is the search request that there will be no problems in searching and reading the request.
GO TO FULL VERSION