Skip to content

List, download and index github repos locally for trigram-based search

License

Notifications You must be signed in to change notification settings

jwbargsten/repo-zoek

Repository files navigation

repo-zoek

List, download and index github repos for trigram-based search on your machine using zoekt.

Preparation

  • Install node >= 12
  • You need to have golang installed
  • You need a github personal access token and it needs to be accessible in the environment as GITHUB_PAT when running

repo-zoek.

Installation

go install github.com/google/zoekt/cmd/zoekt-index@latest
go install github.com/google/zoekt/cmd/zoekt@latest

# make sure npm does not try to install the script to /usr/local/bin or similar
npm config set prefix ~/.npm-pkg
# (TAKE CARE: if you use nvm or similar,
#  make sure that your prefix setting does
#  not interfere with nvm. In case of nvm, you
#  can probably skip it.)

# install repo-zoek
npm install --global <https://link-to-latest-release.tgz>
# (SEE BELOW for the releases page)

(see release page for newest version)

make sure the go & npm bin path is in your $PATH. You can get the path with

# $GOPATH/bin
go env GOPATH
# npm bin dir
npm bin --global

Example:

export PATH="$(go env GOPATH)/bin:$(npm bin -g):$PATH"

Usage

You need a github personal access token and it needs to be accessible in the environment as GITHUB_PAT when running repo-zoek.

Help:

repo-zoek help

Initial setup of a new "project":

repo-zoek init
repo-zoek org list -d /path/to/project/dir

To download everything:

repo-zoek sync all

Search with

zoekt -r -index_dir path/to/search/index 'regex file:scala'

(I would alias zoekt -r -index_dir path/to/search/index to a more convenient command)

Other stuff you can do with the data

Iterate through the repo list and execute a command

jq -r '.name' </path/to/repos.ndjson  | xargs -IREPO echo "abc REPO def"

TODO

  • look for .repo-zoek.json in the current path
  • handle GITHUB_PAT better?

About

List, download and index github repos locally for trigram-based search

Resources

License

Stars

Watchers

Forks

Packages

No packages published