Skip to content

Commit

Permalink
add: do shallow clone (#454)
Browse files Browse the repository at this point in the history
* do git clone with depth 1

* add git shallow clone for fast UI response with fetching rest of history in background

* comment

* fix prettier
  • Loading branch information
nikitavoloboev authored Mar 20, 2023
1 parent 6c8a576 commit 1a6ccec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,30 @@ async function cloneRepository(args: {
if (host === undefined || owner === undefined || repository === undefined) {
return undefined
}

// do shallow clone, get first commit and just one branch
await raw.clone({
fs: args.fs,
http,
dir: "/",
corsProxy: clientSideEnv.VITE_GIT_REQUEST_PROXY_PATH,
url: `https://${host}/${owner}/${repository}`,
singleBranch: true,
depth: 1,
})

// fetch 100 more commits, can get more commits if needed
// https://isomorphic-git.org/docs/en/faq#how-to-make-a-shallow-repository-unshallow
raw.fetch({
fs: args.fs,
http,
dir: "/",
corsProxy: clientSideEnv.VITE_GIT_REQUEST_PROXY_PATH,
url: `https://${host}/${owner}/${repository}`,
depth: 100,
relative: true,
})

// triggering a side effect here to trigger a re-render
// of components that depends on fs
const date = new Date()
Expand Down
3 changes: 2 additions & 1 deletion source-code/website/src/pages/index/repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export const repositories: Repositories = [
{
owner: "knadh",
repository: "listmonk",
description: "High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.",
description:
"High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.",
},
]

Expand Down

0 comments on commit 1a6ccec

Please sign in to comment.