-
Notifications
You must be signed in to change notification settings - Fork 106
feat: Generic git host support (local & remote) #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0ae965c
wip on supporting generic git hosts
brendan-kellam d2ce0c7
wip on hydrating repository info from the db instead of zoekt
brendan-kellam d52216f
bump zoekt version
brendan-kellam 3330921
Further wip
brendan-kellam f9d21ae
wip
brendan-kellam 0363516
wip
brendan-kellam f8ac5cb
docs
brendan-kellam 003a9c3
nit: move search related stuff under /search path
brendan-kellam 495775b
Improve docs in schema
brendan-kellam 3781a8c
feedback
brendan-kellam d2afa22
feedback
brendan-kellam d2985ed
fix build
brendan-kellam 35b5284
feedback
brendan-kellam 9cb85cc
fix Makefile
brendan-kellam be57e9f
use .dereference instead of bundle s.t., we resolve internal refs too
brendan-kellam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: Other Git hosts | ||
--- | ||
|
||
import GenericGitHost from '/snippets/schemas/v3/genericGitHost.schema.mdx' | ||
|
||
Sourcebot can sync code from any Git host (by clone url). This is helpful when you want to search code that not in a [supported code host](/docs/connections/overview#supported-code-hosts). | ||
|
||
## Getting Started | ||
|
||
To connect to a Git host, create a new [connection](/docs/connections/overview) with type `git` and specify the clone url in the `url` property. For example: | ||
|
||
```json | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/sourcebot-dev/sourcebot" | ||
} | ||
``` | ||
|
||
Note that only `http` & `https` URLs are supported at this time. | ||
brendan-kellam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Schema reference | ||
|
||
<Accordion title="Reference"> | ||
[schemas/v3/genericGitHost.json](https://github.com/sourcebot-dev/sourcebot/blob/main/schemas/v3/genericGitHost.json) | ||
|
||
<GenericGitHost /> | ||
|
||
</Accordion> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
title: Local Git repositories | ||
--- | ||
|
||
import GenericGitHost from '/snippets/schemas/v3/genericGitHost.schema.mdx' | ||
|
||
<Note> | ||
This feature is only supported when [self-hosting](/self-hosting/overview). | ||
</Note> | ||
|
||
Sourcebot can sync code from generic git repositories stored in a local directory. This can be helpful in scenarios where you already have a large number of repos already checked out. Local repositories are treated as **read-only**, meaing Sourcebot will **not** `git fetch` new revisions. | ||
|
||
## Getting Started | ||
|
||
<Warning> | ||
Only folders containing git repositories at their root **and** have a `remote.origin.url` set in their git config are supported at this time. All other folders will be skipped. | ||
</Warning> | ||
|
||
Let's assume we have a `repos` directory located at `$(PWD)` with a collection of git repositories: | ||
|
||
```sh | ||
repos/ | ||
├─ repo_1/ | ||
├─ repo_2/ | ||
├─ repo_3/ | ||
├─ ... | ||
``` | ||
|
||
To get Sourcebot to index these repositories: | ||
|
||
<Steps> | ||
<Step title="Mount a volume"> | ||
We need to mount a docker volume to the `repos` directory so Sourcebot can read it's contents. Sourcebot will **not** write to local repositories, so we can mount a seperate **read-only** volume: | ||
|
||
``` bash | ||
docker run \ | ||
-v $(pwd)/repos:/repos:ro \ | ||
/* additional args */ \ | ||
ghcr.io/sourcebot-dev/sourcebot:latest | ||
``` | ||
</Step> | ||
|
||
<Step title="Create a connection"> | ||
We can now create a new git [connection](/docs/connections/overview), specifying local paths with the `file://` prefix. Glob patterns are supported. For example: | ||
|
||
```json | ||
{ | ||
"type": "git", | ||
"url": "file:///repos/*" | ||
} | ||
``` | ||
|
||
Sourcebot will expand this glob pattern into paths `/repos/repo_1`, `/repos/repo_2`, etc. and index all valid git repositories. | ||
</Step> | ||
</Steps> | ||
|
||
## Examples | ||
|
||
|
||
<AccordionGroup> | ||
<Accordion title="Sync individual repo"> | ||
```json | ||
{ | ||
"type": "git", | ||
"url": "file:///path/to/git_repo" | ||
} | ||
``` | ||
</Accordion> | ||
<Accordion title="Sync multiple repos using glob patterns"> | ||
```json | ||
// Attempt to sync directories contained in `repos/` (non-recursive) | ||
{ | ||
"type": "git", | ||
"url": "file:///repos/*" | ||
} | ||
``` | ||
</Accordion> | ||
</AccordionGroup> | ||
|
||
## Schema reference | ||
|
||
<Accordion title="Reference"> | ||
[schemas/v3/genericGitHost.json](https://github.com/sourcebot-dev/sourcebot/blob/main/schemas/v3/genericGitHost.json) | ||
|
||
<GenericGitHost /> | ||
|
||
</Accordion> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,4 +90,5 @@ Additional info: | |
| Bitbucket Data Center | ✅ | | ||
| Gitea | ✅ | | ||
| Gerrit | ❌ | | ||
| Generic git host | ✅ | | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.