CARVIEW |
Finding uses of an API with the new GitHub Code Search
The GitHub Code Search beta is really powerful - it allows advanced search - including regular expression matches - against every public repo on GitHub.
It's still in a preview (December 2022) - you can request access here.
Today I used it to figure out who was using a specific internal API from Datasette that I'm considering changing for Datasette 1.0.
The API is the permission_allowed(self, actor, action, resource=None, default=False)
method - it's intended to be used by plugins that need to check if a user has permission to perform a specific action.
I use it a lot in my own plugins, but I wanted to see if anyone else was using it for theirs.
After some perusing of their documentation I came up with this:
datasette permission_allowed -user:simonw -path:datasette/** -path:docs/** -path:tests/** language:python
-
datasette permission_allowed
searches for files that use both of those terms. I could also have used".permission_allowed("
to find things that are definitely method calls - or crafted a regular expression - but for this search just the keywords worked fine. -
-user:simonw
filters out everything from my own repos - I write a lot of plugins that use this, but I didn't want to see those in the search results -
-path:datasette/**
filters out anything in a file within adatasette/
parent folder. Without this my search was returning results from forks of my own simonw/datasette repository, which I didn't want to see. I was hoping I could exclude-repo:*/datasette
or similar but that's not currently supported. -
-path:docs/** -path:tests/**
do the same thing but for mentions indocs/
ortests/
root dirctories. -
language:python
restricts the results to Python files (presumably.py
and.ipynb
and similar).
If you have access to the beta you can try that search here.
See also my research notes in this issue.
Related
- google Limited JSON API for Google searches using Programmable Search Engine - 2023-09-16
- github Bulk fetching repository details with the GitHub GraphQL API - 2021-01-17
- readthedocs Read the Docs Search API - 2020-08-16
- github-actions Testing against Python 3.11 preview using GitHub Actions - 2022-02-02
- gpt3 Using ChatGPT Browse to name a Python package - 2023-06-18
- datasette Scraping Reddit and writing data to the Datasette write API - 2023-03-13
- homebrew Packaging a Python CLI tool for Homebrew - 2020-08-11
- clickhouse Reviewing your history of public GitHub repositories using ClickHouse - 2024-03-20
- git git bisect - 2022-10-29
- git Rewriting a repo to contain the history of just specific files - 2022-03-22
Created 2022-12-08T18:06:02-08:00 · Edit