Search github repo for term with special characters using sourcegraph? - github

The top answer to How to search on GitHub to get exact string matches, including special characters shows a way to search GitHub for terms that include special characters using a tool called sourcegraph.
I got that working:
https://sourcegraph.com/search?q=context:global+.where%28&patternType=literal
but I'd like to narrow the search to a specific repo (not all of GitHub) - how can I do that?
Example
Here's the exact search I tried on GitHub:
https://github.com/sharetribe/sharetribe/search?q=.where%28
(it searches for where instead of .where(.
Here's the search on sourcegraph:
https://sourcegraph.com/search?q=context:global+.where%28&patternType=literal
It returns results for all of GitHub rather than the specific repo sharetribe/sharetribe.
How can I limit this search to one repo?

You can limit this search by using the repo filter:
https://sourcegraph.com/search?q=context:global+repo:sharetribe/sharetribe+.where%28&patternType=literal

Related

Which names does GitHub recognize as README's?

I know there are several names that get recognized by GitHub as README's, e.g. README, README.md.
What is an exhaustive list of such names?
I found a searching rule
const PATTERN = /^readme\.(?:markdown|mdown|mkdn|md|textile|rdoc|org|creole|mediawiki|wiki|rst|asciidoc|adoc|asc|pod|txt)/i

GitHub Actions workflow syntax not working as expected

I have a GitHub workflow that is triggered when files according to the
pattern **/abc** are modified / created.
As far as I understand it, this means that whenever a:
File that is in some subfolder of a folder that starts with abc or
Any file that starts with abc
is modified, the GH action should be triggered.
However, the workflow is even triggered when I e.g. create a file repository/aaa/test_abc
However, to my understanding, the file repository/aaa/test_abc does not correspond to the pattern **/abc**
Do I
Misunderstand GH actions syntax or is it
A Bug in GH actions?
You need to escape the / with a \ for the pattern to work.
Using '**\/abc**' will resolve the problem.
Most of the time, the filter pattern cheat sheet for the Github Documentation helps to configure the paths, but in that specific case it wasn't detailed.

GitHub: Search for String Inside of a File in a Repo

TLDR: I want to use the GitHub search API to find a list of all repos with a "search-string" inside of the top-level Jenkinsfile. Does GitHub allow that?
I've read numerous SO posts and GitHub search/API docs including:
How to search for code in GitHub with GitHub API?
How to search for code in github, with github API?
https://developer.github.com/v3/search/#search-code
And can't find the answer to my issue.
I'm first trying to use the GitHub code search API to search for a specific substring (only two words with a dash joining them: "search-string") in a specific file, but I can't figure out how to do it. I've tried numerous combinations of simple & advanced searches, but usually get zero results. I.e.
1 result (obvious): repo:repo/redacted
0 results: repo:repo/redacted search-string
0 results: search-string repo:repo/redacted filename:Jenkinsfile
0 results: search-string repo:repo/redacted in:Jenkinsfile
And quite a few more combos.
Once I get it working on the GitHub website, I'll convert it to an API call, which shouldn't be an issue.
Thanks in advance!
I was having a similar problem where I was trying to use the GitHub search web interface to find instances of a particular filename in my code, which had a name including underscore characters and a number, like my_image_asset_2.svg.
Searching on that string within my repository (or organization) unexpectedly returned zero results (in the "Code" results type), using a search term like:
repo:repo/redacted my_image_asset_2.svg
Even trimming out the number and extension from my search term still unexpectedly returned zero results:
repo:repo/redacted my_image_asset
A workaround that finally stumbled on that got GitHub to return the code I was looking for was to (1) drop all punctuation characters from my filename, and (2) enclose the filename in quotes:
repo:repo/redacted "my image asset 2 svg"
This might not be a perfect solution in all cases; I imagine it might also match filenames like my-image-asset-2.svg. But depending on your use case, it might be "good enough"?

How can I search by filename and filter by stars on Github?

According to the Github Advanced Search docs, you can Query for values greater or less than another value using syntax like:
cats stars:>1000
This returns repositories with the word "cats" that have more than 1000 stars.
Also according to the Github Advanced Search guide for Search by filename,
cats filename:package.json
This will return matches for the word "cats" inside the package.json file in repositories.
Given these two features (and possibly others I haven't mentioned here), I would like to search for specific files in repositories that have greater than a given number of stars.
plugin-syntax-dynamic-import filename:babel.config.js stars:>1000
This doesn't currently return the results I'm looking for - it returns matches for plugin-syntax-dynamic-import in babel.config.js but it also returns items with less than 1000 stars.
How can I search by filename and filter by stars on Github?

how to search for gist by name

Is there a way to find a Gist from the name (or description)?
I was watching a YouTube video discussion and one of the participants brought up a Gist. It was too small to read on the video, but the name at the top was clear (dhh/test_induced_design_damage.rb); however, I wasn't able to use that name to find the Gist. (Eventually I found a raw link on a Twitter feed, with a 20-digit hex number. The Gist is public.) I later tried several different searches to see if there was a way I could find it by name, and I tried looking in Github's Help, but I couldn't find a way. Did I miss something, or is there just no way to do this?
If you know the username you can go to https://gist.github.com/username/ and then search through them, but that only works if it's not an anonymously posted or private gist. There's not a nice way to get to a Gist unless you've got the link if you don't know who posted it.
In your case, the Gist is available as the first one at the moment under https://gist.github.com/dhh.
prefixes are available eg filename:*design_damage.rb
top result: dhh / test_induced_design_damage.rb
filename:.bashrc Find all gists with a ".bashrc" file.
cat language:html Find all cat gists with HTML files.
join extension:coffee Find all instances of join in gists with a coffee
extension.
system size:>1000 Find all instances of system in gists
containing a file larger than 1000kbs.
cat stars:>100 Find cat gists with greater than 100 stars.
user:defunkt Get all gists from the user defunkt.
cat anon:true Include anonymous gists in your search for cat-related gists.
NOT cat Excludes all results containing cat.
cat fork:only Search all forked gists for results containing cat.