Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search partial words in GitHub Organization's code

Tags:

git

github

search

Is there a way to grep for partial words inside all code belonging to a GitHub Organization, using the web UI?

Of course, the intent is to avoid having to clone all the organization's repositories and do a local grep; that would be a cumbersome, tedious and error-prone task.

I'm aware of Search code inside a Github project, but I find the search is very misleading as it doesn't really find all results.

For example, I want to find all uses of the string DISABLE_LIBRARIES_GENERATION in all files from the Kurento organization. Using any of these Advanced Search terms

DISABLE_LIBRARIES_GENERATION user:Kurento
DISABLE_LIBRARIES_GENERATION org:Kurento

yields these results:

  • Finds ${DISABLE_LIBRARIES_GENERATION} in kms-core/src/server/CMakeLists.txt.
  • Finds set (DISABLE_LIBRARIES_GENERATION FALSE in kms-core/CMake/CodeGenerator.cmake.
  • Finds the string in kms-core/debian/changelog.
  • Doesn't find -DDISABLE_LIBRARIES_GENERATION=TRUE as used in adm-scripts/kurento_get_version.sh, adm-scripts/kurento_generate_js_module.sh and adm-scripts/kurento_generate_java_module.sh.
like image 445
j1elo Avatar asked May 10 '17 11:05

j1elo


People also ask

How do I search for a specific word in GitHub?

state the specific string you're looking for using the "intext:" search operator. add the programming language you're interested in, using the "ext:" operator (i.e. "ext:py", "ext:R", "ext:rb", etc.) search in all public repos in Github using the "site:" operator mrgloom mentioned.

What must you add around multi word search terms when searching for users in GitHub?

Use quotations around multi-word search terms. For example, if you want to search for issues with the label "In progress," you'd search for label:"in progress" .

How do I search for a file in GitHub organization?

Just press T in the repository's directory view and it will let you search for a file.


1 Answers

The answer to my question is: No, it is not currently possible.

Source
I contacted GitHub with this same question, and their response included this explanation:

Currently, we do not support substring matching in our search. We do break words apart for common variable naming patterns like camel case, so if your variable is named something like myNewVariable, you could search for "my new variable" and this would show up.

However, in your example, the string "-DDISABLE_LIBRARIES_GENERATION=TRUE" wouldn't be broken into substrings like this, so "disable_libraries_generation" would not result in a match.

[...] cloning the repository and using grep or another search functionality locally is likely your best option in this case.

UPDATE (2021-12-14)
On December 8, 2021, GitHub announced code search improvements, including "Search for an exact string, with support for substring matches". This is still a technology preview (available here: https://cs.github.com/), but when fully integrated, looks like it might be a satisfactory answer to this question.

like image 177
j1elo Avatar answered Sep 20 '22 23:09

j1elo