indexPack
Create the .idx file for a given .pack file
param | type [= default] | description |
---|---|---|
fs | FsClient | a file system client |
onProgress | ProgressCallback | optional progress event callback |
dir | string | The working tree directory path |
gitdir | string = join(dir,'.git') | The git directory path |
filepath | string | The path to the .pack file to index |
cache | object | a cache object |
return | Promise<{oids: Array<string>}> | Resolves with a list of the SHA-1 object ids contained in the packfile |
Example Code:
let packfiles = await fs.promises.readdir('/tutorial/.git/objects/pack')
packfiles = packfiles.filter(name => name.endsWith('.pack'))
console.log('packfiles', packfiles)
const { oids } = await git.indexPack({
fs,
dir: '/tutorial',
filepath: `.git/objects/pack/${packfiles[0]}`,
async onProgress (evt) {
console.log(`${evt.phase}: ${evt.loaded} / ${evt.total}`)
}
})
console.log(oids)
Tip: If you need a clean slate, expand and run this snippet to clean up the file system.
window.fs = new LightningFS('fs', { wipe: true })
window.pfs = window.fs.promises
console.log('done')