Page 1 of 2
Searching code on Github (web)
Posted: Thu Mar 26, 2020 11:45 am
by stevestrong
Hi,
a stupid question: is anyone aware how to search for source code on Github (web)?
It seems that Github can only find exact words (case insensitive), or terms including the searched query extended with "_" (underscore).
Partial matches are not detected. Is that right?
For example, I want to find all words containing the term "debug" in a specific repository.
If I only enter "debug", then "debugPorts" is not found, but "debug_port" is found.
What should I enter in the search field in order to also find "debugPorts"?
Re: Searching code on Github (web)
Posted: Thu Mar 26, 2020 1:04 pm
by BennehBoy
Have you tried standard match all operators such as %? Not something I've tried btw.
Re: Searching code on Github (web)
Posted: Thu Mar 26, 2020 1:29 pm
by fpiSTM
I got several times the same issue than you.
And it seems not possible to find using a pattern.
You can try using this:
https://github.com/search/advanced
Here the consideration for search with all the restrictions:
https://help.github.com/en/github/searc ... ode-search
Re: Searching code on Github (web)
Posted: Thu Mar 26, 2020 2:01 pm
by stevestrong
Thanks Frederic, I have already read all those links and many more, but none of them provided answers to my issue.
That is why posted here in the hope that some has a solution.
But it seems that the usage of match operators is not supported, so I think we have to live with this restriction.
Re: Searching code on Github (web)
Posted: Thu Mar 26, 2020 3:22 pm
by fpiSTM
stevestrong wrote: Thu Mar 26, 2020 2:01 pm
But it seems that the usage of match operators is not supported, so I think we have to live with this restriction.
Right.

Re: Searching code on Github (web)
Posted: Fri May 01, 2020 12:18 am
by ahull
Can you use Google or some other search engine to do what you need?
For example put this in google..
Code: Select all
TFT.print(" STM-O-Scope by Andy Hull") ; site:github.com
... and you will see all of the instances of that string on the whole of github.
Modify it to
Code: Select all
TFT.print(" STM-O-Scope by Andy Hull") ; site:github.com/pingumacpenguin/STM32-O-Scope +commit
And you will only see the commit in my repo.
Re: Searching code on Github (web)
Posted: Fri May 01, 2020 9:04 am
by stevestrong
Andy, the problem is with the incomplete word search.
You cannot search only for
it will be not found.
Re: Searching code on Github (web)
Posted: Fri May 01, 2020 9:53 am
by ahull
You could try duckduckgo instead, it does produce results for that search term.
Enter the search you mentioned.
Code: Select all
TFT.print(" STM-O-Sco site:github.com/pingumacpenguin/STM32-O-Scope
This expands to the following in the search URL
Code: Select all
https://duckduckgo.com/?q=TFT.print(%22+STM-O-Sco+site%3Agithub.com%2Fpingumacpenguin%2FSTM32-O-Scope&t=canonical&atb=v192-1&ia=web
.. which produce stuff. Whether these are the droids you are looking for I don't know.
Re: Searching code on Github (web)
Posted: Fri May 01, 2020 10:21 am
by ahull
.. better still, duckduckgo supports Unix style string escaping, so try this string
Code: Select all
"TFT.print(\" STM-O-Sco" site:github.com/pingumacpenguin/STM32-O-Scope
Note the "Escaped" double quote in the string.
Re: Searching code on Github (web)
Posted: Fri May 01, 2020 12:19 pm
by stevestrong
Thanks, it looks much better with duckuck, but it is still not perfect.
I do not see directly the line where the text occurs. Of course the additional CTRL+F on the page helps further.
But: why do I get results from Bodmer's repo when I search the whole github?