Implement depth based pagination for listing Git repo branch content
@thivindu is already working on this.
Since Nov 12, 2025.
- Dominant language
- Go
- Stars
- 71
- Forks
- 111
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 110
Description
Problem
When fetching the content of a Git repository branch, the repository can be large and contain many subdirectories and files.
Loading the entire structure in one response causes performance issues on the frontend due to the large payload size and rendering overhead.
Proposed Solution
Implement depth-based pagination for listing Git repository branch content.
Introduce an optional query parameter depth to limit how deep the repository traversal goes when fetching content.
For example, if depth=2, the API should return all directories and files within two levels from the root of the repository.
The response should include:
- Directories
- Empty directories
- Files
This approach helps balance data completeness and performance by allowing the frontend to load deeper structures incrementally.
Implementation Details
Endpoint:
POST /git/repo/branch/fetch-content
New Query Parameter:
depth (optional, integer) – defines how deep the repo traversal should go.
Example:
/git/repo/branch/fetch-content?depth=2
Sample Response -
[
{
"path": ".samples",
"subPath": ".samples",
"children": [
{
"path": ".samples/icons",
"subPath": "icons",
"children": [],
"type": "tree"
},
{
"path": ".samples/index.json",
"subPath": "index.json",
"children": [],
"type": "blob"
}
],
"type": "tree"
},
{
"path": "chat-service-api",
"subPath": "chat-service-api",
"children": [
{
"path": "chat-service-api/.choreo",
"subPath": ".choreo",
"children": [],
"type": "tree"
},
{
"path": "chat-service-api/asyncapi.yaml",
"subPath": "asyncapi.yaml",
"children": [],
"type": "blob"
}
],
"type": "tree"
},
{
"path": "cloudmersive-currency-api",
"subPath": "cloudmersive-currency-api",
"children": [
{
"path": "cloudmersive-currency-api/openapi.yaml",
"subPath": "openapi.yaml",
"children": [],
"type": "blob"
},
{
"path": "cloudmersive-currency-api/weather-api",
"subPath": "weather-api",
"children": [],
"type": "tree"
}
],
"type": "tree"
},
{
"path": "empty-directory",
"subPath": "empty-directory",
"children": [
{
"path": null,
"subPath": null,
"children": [],
"type": "EOF"
}],
"type": "tree"
}
]
Behavior Notes
children: [] → Indicates the directory has children that were not loaded because of the current depth limit.
{
"path": "cloudmersive-currency-api/weather-api",
"subPath": "weather-api",
"children": [],
"type": "tree"
}
children: ["EOF"] → Explicitly indicates an empty directory (helps distinguish from untraversed nodes).
{
"path": "empty-directory",
"subPath": "empty-directory",
"children": [
{
"path": null,
"subPath": null,
"children": [],
"type": "EOF"
}],
"type": "tree"
}
When the frontend user clicks a directory with children: [], the backend should fetch the next depth level for that subdirectory.
This distinction avoids redundant API calls and improves both performance and user experience.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.