Skip to content

Commit e63adbe

Browse files
committed
Merge main into feature/gerrit-authentication
Resolved merge conflicts in: - packages/backend/src/repoManager.ts: Used main branch cloning logic - packages/web/package.json: Removed duplicate @testing-library/jest-dom dependency - yarn.lock: Regenerated with resolved dependencies
2 parents 48dcf31 + e317407 commit e63adbe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1683
-875
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,3 @@ dist
165165
/config.json
166166
.DS_Store
167167

168-
# Claude Code generated files
169-
CLAUDE.md

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [4.6.5] - 2025-09-02
11+
12+
### Fixed
13+
- Remove setting `remote.origin.url` for remote git repositories. [#483](https://github.com/sourcebot-dev/sourcebot/pull/483)
14+
- Fix error when navigating to paths with percentage symbols. [#485](https://github.com/sourcebot-dev/sourcebot/pull/485)
15+
16+
### Changed
17+
- Updated NextJS to version 15. [#477](https://github.com/sourcebot-dev/sourcebot/pull/477)
18+
- Add `sessionToken` as optional Bedrock configuration parameter. [#478](https://github.com/sourcebot-dev/sourcebot/pull/478)
19+
1020
## [4.6.4] - 2025-08-11
1121

1222
### Added

docs/docs/configuration/language-model-providers.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ For a detailed description of all the providers, please refer to the [schema](ht
6767
"accessKeySecret": {
6868
"env": "AWS_SECRET_ACCESS_KEY"
6969
},
70+
"sessionToken": {
71+
"env": "AWS_SESSION_TOKEN"
72+
},
7073
"region": "YOUR_REGION_HERE", // defaults to the AWS_REGION env var if not set
7174
"baseUrl": "OPTIONAL_BASE_URL"
7275
}

docs/snippets/schemas/v3/index.schema.mdx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,39 @@
13551355
}
13561356
]
13571357
},
1358+
"sessionToken": {
1359+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
1360+
"anyOf": [
1361+
{
1362+
"type": "object",
1363+
"properties": {
1364+
"secret": {
1365+
"type": "string",
1366+
"minLength": 1,
1367+
"description": "The name of the secret that contains the token."
1368+
}
1369+
},
1370+
"required": [
1371+
"secret"
1372+
],
1373+
"additionalProperties": false
1374+
},
1375+
{
1376+
"type": "object",
1377+
"properties": {
1378+
"env": {
1379+
"type": "string",
1380+
"minLength": 1,
1381+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
1382+
}
1383+
},
1384+
"required": [
1385+
"env"
1386+
],
1387+
"additionalProperties": false
1388+
}
1389+
]
1390+
},
13581391
"region": {
13591392
"type": "string",
13601393
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",
@@ -2749,6 +2782,39 @@
27492782
}
27502783
]
27512784
},
2785+
"sessionToken": {
2786+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
2787+
"anyOf": [
2788+
{
2789+
"type": "object",
2790+
"properties": {
2791+
"secret": {
2792+
"type": "string",
2793+
"minLength": 1,
2794+
"description": "The name of the secret that contains the token."
2795+
}
2796+
},
2797+
"required": [
2798+
"secret"
2799+
],
2800+
"additionalProperties": false
2801+
},
2802+
{
2803+
"type": "object",
2804+
"properties": {
2805+
"env": {
2806+
"type": "string",
2807+
"minLength": 1,
2808+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
2809+
}
2810+
},
2811+
"required": [
2812+
"env"
2813+
],
2814+
"additionalProperties": false
2815+
}
2816+
]
2817+
},
27522818
"region": {
27532819
"type": "string",
27542820
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",

docs/snippets/schemas/v3/languageModel.schema.mdx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,39 @@
8585
}
8686
]
8787
},
88+
"sessionToken": {
89+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
90+
"anyOf": [
91+
{
92+
"type": "object",
93+
"properties": {
94+
"secret": {
95+
"type": "string",
96+
"minLength": 1,
97+
"description": "The name of the secret that contains the token."
98+
}
99+
},
100+
"required": [
101+
"secret"
102+
],
103+
"additionalProperties": false
104+
},
105+
{
106+
"type": "object",
107+
"properties": {
108+
"env": {
109+
"type": "string",
110+
"minLength": 1,
111+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
112+
}
113+
},
114+
"required": [
115+
"env"
116+
],
117+
"additionalProperties": false
118+
}
119+
]
120+
},
88121
"region": {
89122
"type": "string",
90123
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",
@@ -1479,6 +1512,39 @@
14791512
}
14801513
]
14811514
},
1515+
"sessionToken": {
1516+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
1517+
"anyOf": [
1518+
{
1519+
"type": "object",
1520+
"properties": {
1521+
"secret": {
1522+
"type": "string",
1523+
"minLength": 1,
1524+
"description": "The name of the secret that contains the token."
1525+
}
1526+
},
1527+
"required": [
1528+
"secret"
1529+
],
1530+
"additionalProperties": false
1531+
},
1532+
{
1533+
"type": "object",
1534+
"properties": {
1535+
"env": {
1536+
"type": "string",
1537+
"minLength": 1,
1538+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
1539+
}
1540+
},
1541+
"required": [
1542+
"env"
1543+
],
1544+
"additionalProperties": false
1545+
}
1546+
]
1547+
},
14821548
"region": {
14831549
"type": "string",
14841550
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
"dotenv-cli": "^8.0.0",
2525
"npm-run-all": "^4.1.5"
2626
},
27-
"packageManager": "yarn@4.7.0"
27+
"packageManager": "yarn@4.7.0",
28+
"resolutions": {
29+
"prettier": "3.5.3"
30+
}
2831
}

packages/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@types/micromatch": "^4.0.9",
1616
"@types/node": "^22.7.5",
1717
"cross-env": "^7.0.3",
18-
"json-schema-to-typescript": "^15.0.2",
18+
"json-schema-to-typescript": "^15.0.4",
1919
"tsc-watch": "^6.2.0",
2020
"tsx": "^4.19.1",
2121
"typescript": "^5.6.2",

packages/backend/src/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const env = createEnv({
4343

4444
LOGTAIL_TOKEN: z.string().optional(),
4545
LOGTAIL_HOST: z.string().url().optional(),
46+
SOURCEBOT_LOG_LEVEL: z.enum(["info", "debug", "warn", "error"]).default("info"),
4647

4748
DATABASE_URL: z.string().url().default("postgresql://postgres:postgres@localhost:5432/postgres"),
4849
CONFIG_PATH: z.string().optional(),

packages/backend/src/git.ts

Lines changed: 80 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,72 @@
11
import { CheckRepoActions, GitConfigScope, simpleGit, SimpleGitProgressEvent } from 'simple-git';
2+
import { mkdir } from 'node:fs/promises';
3+
import { env } from './env.js';
24

35
type onProgressFn = (event: SimpleGitProgressEvent) => void;
46

5-
export const cloneRepository = async (cloneURL: string, path: string, onProgress?: onProgressFn) => {
6-
const git = simpleGit({
7-
progress: onProgress,
8-
});
7+
export const cloneRepository = async (
8+
remoteUrl: URL,
9+
path: string,
10+
onProgress?: onProgressFn
11+
) => {
912
try {
10-
await git.clone(
11-
cloneURL,
12-
path,
13-
[
14-
"--bare",
15-
]
16-
);
13+
await mkdir(path, { recursive: true });
1714

18-
await git.cwd({
15+
const git = simpleGit({
16+
progress: onProgress,
17+
}).cwd({
1918
path,
20-
}).addConfig("remote.origin.fetch", "+refs/heads/*:refs/heads/*");
19+
})
20+
21+
await git.init(/*bare = */ true);
22+
23+
await git.fetch([
24+
remoteUrl.toString(),
25+
// See https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
26+
"+refs/heads/*:refs/heads/*",
27+
"--progress",
28+
]);
2129
} catch (error: unknown) {
22-
if (error instanceof Error) {
23-
throw new Error(`Failed to clone repository: ${error.message}`);
30+
const baseLog = `Failed to clone repository: ${path}`;
31+
32+
if (env.SOURCEBOT_LOG_LEVEL !== "debug") {
33+
// Avoid printing the remote URL (that may contain credentials) to logs by default.
34+
throw new Error(`${baseLog}. Set environment variable SOURCEBOT_LOG_LEVEL=debug to see the full error message.`);
35+
} else if (error instanceof Error) {
36+
throw new Error(`${baseLog}. Reason: ${error.message}`);
2437
} else {
25-
throw new Error(`Failed to clone repository: ${error}`);
38+
throw new Error(`${baseLog}. Error: ${error}`);
2639
}
2740
}
28-
}
29-
30-
31-
export const fetchRepository = async (path: string, onProgress?: onProgressFn) => {
32-
const git = simpleGit({
33-
progress: onProgress,
34-
});
41+
};
3542

43+
export const fetchRepository = async (
44+
remoteUrl: URL,
45+
path: string,
46+
onProgress?: onProgressFn
47+
) => {
3648
try {
37-
await git.cwd({
49+
const git = simpleGit({
50+
progress: onProgress,
51+
}).cwd({
3852
path: path,
39-
}).fetch(
40-
"origin",
41-
[
42-
"--prune",
43-
"--progress"
44-
]
45-
);
53+
})
54+
55+
await git.fetch([
56+
remoteUrl.toString(),
57+
"+refs/heads/*:refs/heads/*",
58+
"--prune",
59+
"--progress"
60+
]);
4661
} catch (error: unknown) {
47-
if (error instanceof Error) {
48-
throw new Error(`Failed to fetch repository ${path}: ${error.message}`);
62+
const baseLog = `Failed to fetch repository: ${path}`;
63+
if (env.SOURCEBOT_LOG_LEVEL !== "debug") {
64+
// Avoid printing the remote URL (that may contain credentials) to logs by default.
65+
throw new Error(`${baseLog}. Set environment variable SOURCEBOT_LOG_LEVEL=debug to see the full error message.`);
66+
} else if (error instanceof Error) {
67+
throw new Error(`${baseLog}. Reason: ${error.message}`);
4968
} else {
50-
throw new Error(`Failed to fetch repository ${path}: ${error}`);
69+
throw new Error(`${baseLog}. Error: ${error}`);
5170
}
5271
}
5372
}
@@ -76,6 +95,33 @@ export const upsertGitConfig = async (path: string, gitConfig: Record<string, st
7695
}
7796
}
7897

98+
/**
99+
* Unsets the specified keys in the git config for the repo at the given path.
100+
* If a key is not set, this is a no-op.
101+
*/
102+
export const unsetGitConfig = async (path: string, keys: string[], onProgress?: onProgressFn) => {
103+
const git = simpleGit({
104+
progress: onProgress,
105+
}).cwd(path);
106+
107+
try {
108+
const configList = await git.listConfig();
109+
const setKeys = Object.keys(configList.all);
110+
111+
for (const key of keys) {
112+
if (setKeys.includes(key)) {
113+
await git.raw(['config', '--unset', key]);
114+
}
115+
}
116+
} catch (error: unknown) {
117+
if (error instanceof Error) {
118+
throw new Error(`Failed to unset git config ${path}: ${error.message}`);
119+
} else {
120+
throw new Error(`Failed to unset git config ${path}: ${error}`);
121+
}
122+
}
123+
}
124+
79125
/**
80126
* Returns true if `path` is the _root_ of a git repository.
81127
*/

0 commit comments

Comments
 (0)