Skip to content
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

RFC: Bitbucket support #143

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py,ts}]
charset = utf-8

# Tab indentation (no size specified)
# 'go fmt' uses tabs
[{Makefile,*.mk,*.go}]
indent_style = tab

# Indentation override for JS
[{*.js,*.ts,*.json}]
indent_style = space
indent_size = 4
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,5 @@ dist
.sourcebot
/bin
/config.json
.DS_Store
.DS_Store
.*.sw*
101 changes: 99 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ https://github.com/user-attachments/assets/98d46192-5469-430f-ad9e-5c042adbb10d

## Features
- 💻 **One-command deployment**: Get started instantly using Docker on your own machine.
- 🔍 **Multi-repo search**: Effortlessly index and search through multiple public and private repositories in GitHub, GitLab, Gitea, or Gerrit.
- 🔍 **Multi-repo search**: Effortlessly index and search through multiple public and private repositories in GitHub, GitLab, Gitea, Gerrit, or Bitbucket (Cloud or Data Center).
- ⚡**Lightning fast performance**: Built on top of the powerful [Zoekt](https://github.com/sourcegraph/zoekt) search engine.
- 📂 **Full file visualization**: Instantly view the entire file when selecting any search result.
- 🎨 **Modern web app**: Enjoy a sleek interface with features like syntax highlighting, light/dark mode, and vim-style navigation
Expand Down Expand Up @@ -62,7 +62,7 @@ Sourcebot supports indexing and searching through public and private repositorie
<picture>
<source media="(prefers-color-scheme: dark)" srcset=".github/images/github-favicon-inverted.png">
<img src="https://github.com/favicon.ico" width="16" height="16" alt="GitHub icon">
</picture> GitHub, <img src="https://gitlab.com/favicon.ico" width="16" height="16" /> GitLab, <img src="https://gitea.com/favicon.ico" width="16" height="16"> Gitea, and <img src="https://gerrit-review.googlesource.com/favicon.ico" width="16" height="16"> Gerrit. This section will guide you through configuring the repositories that Sourcebot indexes.
</picture> GitHub, <img src="https://gitlab.com/favicon.ico" width="16" height="16" /> GitLab, <img src="https://gitea.com/favicon.ico" width="16" height="16"> Gitea, <img src="https://gerrit-review.googlesource.com/favicon.ico" width="16" height="16"> Gerrit, and <img src="https://bitbucket.org/favicon.ico" width="16" height="16"> Bitbucket. This section will guide you through configuring the repositories that Sourcebot indexes.

1. Create a new folder on your machine that stores your configs and `.sourcebot` cache, and navigate into it:
```sh
Expand Down Expand Up @@ -266,6 +266,103 @@ docker run -e <b>GITEA_TOKEN=my-secret-token</b> /* additional args */ ghcr.io/s
Gerrit authentication is not yet currently supported.
</details>

<details>
<summary><img src="https://bitbucket.org/favicon.ico" width="16" height="16"> Bitbucket Cloud</summary>

Generate an API key [here](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/). At a minimum, you'll need to select the `read:repository` scope, but `read:user` and `read:organization` are required for the `user` and `org` fields of your config file:

![Bitbucket Cloud Access token creation](.github/images/gitea-pat-creation.png)

Next, update your configuration with the `token` field:
```json
{
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v2/index.json",
"repos": [
{
"type": "bitbucket",
"user": "bitbucket-user",
"token": "my-secret-token",
...
}
]
}
```

You can also pass tokens as environment variables:
```json
{
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v2/index.json",
"repos": [
{
"type": "bitbucket",
"user": "bitbucket-user",
"token": {
// note: this env var can be named anything. It
// doesn't need to be `BITBUCKET_TOKEN`.
"env": "BITBUCKET_TOKEN"
},
...
}
]
}
```

You'll need to pass this environment variable each time you run Sourcebot:

<pre>
docker run -e <b>BITBUCKET_TOKEN=my-secret-token</b> /* additional args */ ghcr.io/sourcebot-dev/sourcebot:latest
</pre>

</details>

<details>
<summary><img src="https://bitbucket.org/favicon.ico" width="16" height="16"> Bitbucket Data Center</summary>

Generate an API key [here](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/). At a minimum, you'll need to select the `read:repository` scope, but `read:user` and `read:organization` are required for the `user` and `org` fields of your config file:

![Bitbucket Data Center Access token creation](.github/images/gitea-pat-creation.png)

Next, update your configuration with the `token` field:
```json
{
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v2/index.json",
"repos": [
{
"type": "bitbucket",
"serverType": "server",
"token": "my-secret-token",
...
}
]
}
```

You can also pass tokens as environment variables:
```json
{
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v2/index.json",
"repos": [
{
"type": "bitbucket",
"serverType": "server",
"token": {
// note: this env var can be named anything. It
// doesn't need to be `BITBUCKET_TOKEN`.
"env": "BITBUCKET_TOKEN"
},
...
}
]
}
```

You'll need to pass this environment variable each time you run Sourcebot:

<pre>
docker run -e <b>BITBUCKET_TOKEN=my-secret-token</b> /* additional args */ ghcr.io/sourcebot-dev/sourcebot:latest
</pre>

</details>

</div>

Expand Down
14 changes: 14 additions & 0 deletions configs/bitbucket-cloud.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "../schemas/v2/index.json",
// Note: to include private repositories, you must provide an authentication token.
// See: configs/auth.json for a example.
"repos": [
// From bitbucket, include:
// - all repos in workspaces owned by user
{
"type": "bitbucket",
"token": "BB_TOKEN",
"user": "user1"
}
]
}
21 changes: 21 additions & 0 deletions configs/bitbucket-server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "../schemas/v2/index.json",
// Note: to include private repositories, you must provide an authentication token.
// See: configs/auth.json for a example.
"repos": [
// From bitbucket, include:
// - all repos in workspaces owned by user
{
"type": "bitbucket",
"url": "http://localhost:4010",
"token": "<use your token here>",
"serverType": "server",
"revisions": {
"branches": [
"main",
"master"
]
}
}
]
}
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@gitbeaker/rest": "^40.5.1",
"@octokit/rest": "^21.0.2",
"argparse": "^2.0.1",
"@coderabbitai/bitbucket": "^1.1.1",
"cross-fetch": "^4.0.0",
"dotenv": "^16.4.5",
"gitea-js": "^1.22.0",
Expand Down
Loading
Loading