Searching code on Github (web)

Anything not related to STM32
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Searching code on Github (web)

Post 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"?
BennehBoy
Posts: 135
Joined: Sat Jan 04, 2020 2:38 am
Answers: 1

Re: Searching code on Github (web)

Post by BennehBoy »

Have you tried standard match all operators such as %? Not something I've tried btw.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Searching code on Github (web)

Post 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
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Searching code on Github (web)

Post 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.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Searching code on Github (web)

Post 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. :roll:
ahull
Posts: 5
Joined: Wed Feb 19, 2020 1:21 pm

Re: Searching code on Github (web)

Post 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.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Searching code on Github (web)

Post by stevestrong »

Andy, the problem is with the incomplete word search.
You cannot search only for

Code: Select all

TFT.print(" STM-O-Sco
it will be not found.
ahull
Posts: 5
Joined: Wed Feb 19, 2020 1:21 pm

Re: Searching code on Github (web)

Post by ahull »

You could try duckduckgo instead, it does produce results for that search term.

Code: Select all

https://duckduckgo.com
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.
ahull
Posts: 5
Joined: Wed Feb 19, 2020 1:21 pm

Re: Searching code on Github (web)

Post 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.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Searching code on Github (web)

Post 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?
Post Reply

Return to “Off topic”