diff --git a/CHANGELOG.md b/CHANGELOG.md index 827714d9..baf12cf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Local directory indexing support. ([#56](https://github.com/sourcebot-dev/sourcebot/pull/56)) + ## [2.2.0] - 2024-10-30 ### Added diff --git a/Dockerfile b/Dockerfile index 3af8b3e5..7e5a1955 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,6 +76,7 @@ COPY --from=zoekt-builder \ /cmd/zoekt-mirror-gitlab \ /cmd/zoekt-mirror-gerrit \ /cmd/zoekt-webserver \ + /cmd/zoekt-index \ /usr/local/bin/ # Configure the webapp diff --git a/README.md b/README.md index e23c0920..f4c7b21a 100644 --- a/README.md +++ b/README.md @@ -267,6 +267,37 @@ docker run -e GITEA_TOKEN=my-secret-token /* additional args */ ghcr.io/s If you're using a self-hosted GitLab or GitHub instance with a custom domain, you can specify the domain in your config file. See [configs/self-hosted.json](configs/self-hosted.json) for examples. +## Searching a local directory + +Local directories can be searched by using the `local` type in your config file: + +```jsonc +{ + "$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v2/index.json", + "repos": [ + { + "type": "local", + "path": "/repos/my-repo", + // re-index files when a change is detected + "watch": true, + "exclude": { + // exclude paths from being indexed + "paths": [ + "node_modules", + "build" + ] + } + } + ] +} +``` + +You'll need to mount the directory as a volume when running Sourcebot: + +
+docker run -v /path/to/my-repo:/repos/my-repo /* additional args */ ghcr.io/sourcebot-dev/sourcebot:latest ++ ## Build from source >[!NOTE] > Building from source is only required if you'd like to contribute. The recommended way to use Sourcebot is to use the [pre-built docker image](https://github.com/sourcebot-dev/sourcebot/pkgs/container/sourcebot). diff --git a/configs/auth.json b/configs/auth.json index ce328e02..14274eb9 100644 --- a/configs/auth.json +++ b/configs/auth.json @@ -17,6 +17,13 @@ "my-group" ] }, + { + "type": "gitea", + "token": "gitea-token", + "orgs": [ + "my-org" + ] + }, // You can also store the token in a environment variable and then // references it from the config. @@ -34,6 +41,15 @@ "groups": [ "my-group" ] + }, + { + "type": "gitea", + "token": { + "env": "GITEA_TOKEN_ENV_VAR" + }, + "orgs": [ + "my-org" + ] } ] } \ No newline at end of file diff --git a/configs/basic.json b/configs/basic.json index 38ddcb8b..78b8588e 100644 --- a/configs/basic.json +++ b/configs/basic.json @@ -37,6 +37,28 @@ "projects": [ "my-group/project1" ] + }, + // From Gitea, include: + // - all public repos owned by user `my-user` + // - all public repos owned by organization `my-org` + // - repo `my-org/my-repo` + { + "type": "gitea", + "token": "my-token", + "users": [ + "my-user" + ], + "orgs": [ + "my-org" + ], + "repos": [ + "my-org/my-repo" + ] + }, + // Index a local repository + { + "type": "local", + "path": "/path/to/local/repo" } ] } \ No newline at end of file diff --git a/configs/filter.json b/configs/filter.json index f072cd7e..1e31d524 100644 --- a/configs/filter.json +++ b/configs/filter.json @@ -37,6 +37,25 @@ "my-group/project2" ] } - } + }, + + // Include all repos in my-org, except: + // - repo1 & repo2 + // - repos that are archived or forks + { + "type": "gitea", + "token": "my-token", + "orgs": [ + "my-org" + ], + "exclude": { + "archived": true, + "forks": true, + "repos": [ + "my-org/repo1", + "my-org/repo2" + ] + } + }, ] } \ No newline at end of file diff --git a/configs/local-repo.json b/configs/local-repo.json new file mode 100644 index 00000000..8c1647d4 --- /dev/null +++ b/configs/local-repo.json @@ -0,0 +1,32 @@ +{ + "$schema": "../schemas/v2/index.json", + "repos": [ + { + "type": "local", + "path": "/path/to/local/repo" + }, + // Relative paths are relative to the config file + { + "type": "local", + "path": "../../relative/path/to/local/repo" + }, + // File watcher can be disabled (enabled by default) + { + "type": "local", + "path": "/path/to/local/repo", + "watch": false + }, + // Exclude paths can be specified + { + "type": "local", + "path": "/path/to/local/repo", + "exclude": { + "paths": [ + ".git", + "node_modules", + "dist" + ] + } + } + ] +} \ No newline at end of file diff --git a/configs/self-hosted.json b/configs/self-hosted.json index 0ea32be3..96695d1f 100644 --- a/configs/self-hosted.json +++ b/configs/self-hosted.json @@ -14,6 +14,13 @@ "groups": [ "my-group" ] + }, + { + "type": "gitea", + "url": "https://gitea.example.com", + "orgs": [ + "my-org-name" + ] } ] } \ No newline at end of file diff --git a/packages/backend/src/db.ts b/packages/backend/src/db.ts index 84ea69fd..6cc59cd8 100644 --- a/packages/backend/src/db.ts +++ b/packages/backend/src/db.ts @@ -14,7 +14,7 @@ export const loadDB = async (ctx: AppContext): Promise