Skip to content

Commit 52ecea8

Browse files
authored
feat: support submodules for GitHub Integration (#147)
1 parent e93b312 commit 52ecea8

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

src/pages/ProfilesExplorerView/components/SceneExploreServiceFlameGraph/components/SceneFunctionDetailsPanel/components/CodeContainer/domain/useCodeContainer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ export function useCodeContainer(dataSourceUid: string, functionDetails: Functio
2020
} = useFetchVCSFile({
2121
enabled: isLoggedIn,
2222
dataSourceUid,
23-
path: functionDetails.fileName,
23+
localPath: functionDetails.fileName,
2424
repository: version?.repository ?? '',
2525
gitRef: version?.git_ref ?? '',
26+
rootPath: version?.root_path ?? '',
2627
});
2728

2829
// might be a bit costly so we memoize it

src/pages/ProfilesExplorerView/components/SceneExploreServiceFlameGraph/components/SceneFunctionDetailsPanel/components/CodeContainer/infrastructure/useFetchVCSFile.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ type FetchParams = {
88
dataSourceUid: string;
99
repository: string;
1010
gitRef: string;
11-
path: string;
11+
localPath: string;
12+
rootPath: string;
1213
};
1314

1415
type FetchResponse = {
@@ -20,15 +21,14 @@ type FetchResponse = {
2021
};
2122
};
2223

23-
export function useFetchVCSFile({ enabled, dataSourceUid, repository, gitRef, path }: FetchParams): FetchResponse {
24+
export function useFetchVCSFile({ enabled, dataSourceUid, repository, gitRef, localPath, rootPath }: FetchParams): FetchResponse {
2425
const privateVcsClient = DataSourceProxyClientBuilder.build(dataSourceUid, PrivateVcsClient);
25-
2626
const { isFetching, error, data } = useQuery({
27-
enabled: Boolean(enabled && path),
28-
queryKey: ['vcs-file', repository, gitRef, path],
27+
enabled: Boolean(enabled && localPath),
28+
queryKey: ['vcs-file', repository, gitRef, localPath, rootPath],
2929
queryFn: () =>
3030
privateVcsClient
31-
.getFile(repository, gitRef, path)
31+
.getFile(repository, gitRef, localPath, rootPath)
3232
.then((code) => ({
3333
content: code.content,
3434
URL: code.URL,

src/pages/ProfilesExplorerView/components/SceneExploreServiceFlameGraph/components/SceneFunctionDetailsPanel/components/GitHubContextProvider/infrastructure/PrivateVcsClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ export class PrivateVcsClient extends DataSourceProxyClient {
6969
* @param localPath A file path relative to the repository root
7070
* @returns Base64 encoded file contents.
7171
*/
72-
async getFile(repositoryUrl: string, gitRef: string, localPath: string): Promise<GetFileResponse> {
72+
async getFile(repositoryUrl: string, gitRef: string, localPath: string, rootPath: string): Promise<GetFileResponse> {
7373
const response = await this.postWithRefresh(
7474
'/vcs.v1.VCSService/GetFile',
7575
JSON.stringify({
7676
repositoryURL: repositoryUrl,
7777
ref: gitRef,
7878
localPath,
79+
rootPath,
7980
})
8081
);
8182

src/pages/ProfilesExplorerView/components/SceneExploreServiceFlameGraph/components/SceneFunctionDetailsPanel/domain/types/FunctionDetails.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export type FunctionVersion = {
22
repository: string;
33
git_ref: string;
4+
root_path: string;
45
};
56

67
export type Commit = {

src/pages/ProfilesExplorerView/components/SceneExploreServiceFlameGraph/components/SceneFunctionDetailsPanel/infrastructure/fetchCommitsInfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export async function fetchCommitsInfo(
1111
const commits = functionsDetails.map((details) => ({
1212
repositoryUrl: details?.version?.repository || '',
1313
gitRef: details?.version?.git_ref || 'HEAD',
14+
rootPath: details?.version?.root_path || '',
1415
}));
1516

1617
// TODO: extract to its own hook and simplify useSceneFunctionDetailsPanel()?

0 commit comments

Comments
 (0)