How can i search file name in specific Github repository
Answer a question
With Github's search API, i can search for repository's name or user's name.
How can i search the file name in the specific Github repository?
I mean how can i do that: in repo jquery/jquery, i search for "selector" keyword, i will have selector.js, selector-sizzle.js, selector-native.js and selector-folder
Thank you
Answers
2014: One workaround would be to do a code search, with:
q: a word than you know is in the file you are looking forfilename: the name of the file you are looking for (see "Search by filename")
For instance, if you are looking for classes.js in the repo jquery/jquery, which you know has to contain the word 'addClass':
https://api.github.com/search/code?q=addClass+repo:jquery/jquery+filename:classes.js
Take the result with a score > 1
"name": "classes.js",
"path": "src/attributes/classes.js",
braitsch adds in the comments:
Instead of "
score", inspect the "total_count" property of the object returned by the query as "score" will be absent if the requested file is not found.
2022: Mikhail Vlasenko points to the current "Searching code", adding:
On the current version, no workaround is necessary, as the search term can be empty when searching with filename.
Except with
filenamesearches, you must always include at least one search term when searching source code. For example, searching forlanguage:javascriptis not valid, whileamazing language:javascriptis.
更多推荐


所有评论(0)