Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/src/git-source-provider.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/git-source-provider.ts')
-rw-r--r--src/git-source-provider.ts32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts
index 48f20da..8f9d63f 100644
--- a/src/git-source-provider.ts
+++ b/src/git-source-provider.ts
@@ -153,23 +153,26 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
// Fetch
core.startGroup('Fetching the repository')
+ const fetchOptions: {filter?: string; fetchDepth?: number} = {}
+ if (settings.sparseCheckout) fetchOptions.filter = 'blob:none'
if (settings.fetchDepth <= 0) {
// Fetch all branches and tags
let refSpec = refHelper.getRefSpecForAllHistory(
settings.ref,
settings.commit
)
- await git.fetch(refSpec)
+ await git.fetch(refSpec, fetchOptions)
// When all history is fetched, the ref we're interested in may have moved to a different
// commit (push or force push). If so, fetch again with a targeted refspec.
if (!(await refHelper.testRef(git, settings.ref, settings.commit))) {
refSpec = refHelper.getRefSpec(settings.ref, settings.commit)
- await git.fetch(refSpec)
+ await git.fetch(refSpec, fetchOptions)
}
} else {
+ fetchOptions.fetchDepth = settings.fetchDepth
const refSpec = refHelper.getRefSpec(settings.ref, settings.commit)
- await git.fetch(refSpec, settings.fetchDepth)
+ await git.fetch(refSpec, fetchOptions)
}
core.endGroup()
@@ -185,12 +188,24 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
// LFS fetch
// Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
// Explicit lfs fetch will fetch lfs objects in parallel.
- if (settings.lfs) {
+ // For sparse checkouts, let `checkout` fetch the needed objects lazily.
+ if (settings.lfs && !settings.sparseCheckout) {
core.startGroup('Fetching LFS objects')
await git.lfsFetch(checkoutInfo.startPoint || checkoutInfo.ref)
core.endGroup()
}
+ // Sparse checkout
+ if (settings.sparseCheckout) {
+ core.startGroup('Setting up sparse checkout')
+ if (settings.sparseCheckoutConeMode) {
+ await git.sparseCheckout(settings.sparseCheckout)
+ } else {
+ await git.sparseCheckoutNonConeMode(settings.sparseCheckout)
+ }
+ core.endGroup()
+ }
+
// Checkout
core.startGroup('Checking out the ref')
await git.checkout(checkoutInfo.ref, checkoutInfo.startPoint)
@@ -261,7 +276,11 @@ export async function cleanup(repositoryPath: string): Promise<void> {
let git: IGitCommandManager
try {
- git = await gitCommandManager.createCommandManager(repositoryPath, false)
+ git = await gitCommandManager.createCommandManager(
+ repositoryPath,
+ false,
+ false
+ )
} catch {
return
}
@@ -297,7 +316,8 @@ async function getGitCommandManager(
try {
return await gitCommandManager.createCommandManager(
settings.repositoryPath,
- settings.lfs
+ settings.lfs,
+ settings.sparseCheckout != null
)
} catch (err) {
// Git is required for LFS