I would like to do a code search in a collection of repositories. I would like to restrict my search using a pattern or naming convention in the repository name.
1) I can limit my search by the organization.
Example: "user:google"
2) I can search a single repository directly.
Example: "repo:google/devtoolsExtended test"
So, is it possible to search all repositories that begin with a pattern?
Equivalent to: "repo:google/dev* test"
In order to search for repositories all you need to do is just type in your query, like the following:
https://github.com/search?q=foo
This finds repos such as FooTable and foodme as well, as if we searched for foo*. If you want to limit your search to the repository name only, use in:name, which results in:
https://github.com/search?q=foo+in%3Aname&type=Repositories
There's no explicit method of searching by begins with or using wildcards, but results for those kinds of searches appear as well.
Sources:
GitHub Help: Searching repositories
Related
My objective is to count the number of repositories that use PyTorch. Therefore, I came up with the following code, using the THUNDER CLIENT extension in VS Code -
https://api.github.com/search/repositories?q=language:python + readme:PyTorch
However, this gives me just 7 search results. I am confident the result should be in the range of thousands. Could someone suggest where I am going wrong?
The GitHub search API for repositories checks the name, description and the README of all repositories.
Therefore, all that was needed to be done was -
https://api.github.com/search/repositories?q=PyTorch
I want to find a string (say XYZ) in a yaml file. But my search should only list repos written in Java language.
I tried something like this. But this doesn't yield any results.
"search_string" filename:abc.yamls language:Java
In github search, the following string allows me to search JavaScript code that contain Acode in all the repositories of the user NameOfUser:
user:NameOfUser language:JavaScript ACode
Now, I would like to add another condition: i am only interested in the code containing ACode in the repositories whose name contains repokey.
Does anyone know how to write the request?
The search API already does this. You can just use the search that you've posted above to search for repositories containing the text you've specified.
For example...
user:mrdoob language:JavaScript Three Extension
returns this...
https://github.com/search?utf8=%E2%9C%93&q=user%3Amrdoob+language%3AJavaScript+Three+Extension&type=Repositories&ref=searchresults
As above answer I also tried with type=Code and added a "WebGLBufferRenderer" keyword, See if it helps:
https://github.com/search?utf8=%E2%9C%93&q=user%3Amrdoob+language%3AThree+Extension+WebGLBufferRenderer&type=Code&ref=searchresults
I was trying to search Github for all repositories that contains the word article in the readme.
I tried two methods:
API: https://api.github.com/search/repositories?q=article&in=readme.
Github Search box: https://github.com/search?utf8=%E2%9C%93&q=article+in%3Areadme&type=Repositories&ref=searchresults
The first methods says there are total 9921 results, "total_count": 9921, whereas the search box finds 77638 repositories.
Why the discrepancy?
The advanced search page shows that:
in: is only for code search
a general term is used for all searches (-in: is ignored for those searches, except for code search)
So:
9921 is the number of readme file with article in it
77638 is the number of repo including an article file, or artienter code herecle in their titles.
Is there a way to find all repositories on github that contain a given commit (given its SHA)?
I can find easily check if a given commit exists in a known repository by checking the existence of
https://github.com/${USER}/${REPO}/commit/${SHA}
...but what if I don't know the repo-slug?
Doing a simple search on SHAs (via the webinterface) doesn't return anything.