resolveRef
Get the value of a symbolic ref or resolve a ref to its SHA-1 object id
param | type [= default] | description |
---|---|---|
fs | FsClient | a file system client |
dir | string | The working tree directory path |
gitdir | string = join(dir, '.git') | The git directory path |
ref | string | The ref to resolve |
depth | number | How many symbolic references to follow before returning |
return | Promise<string> | Resolves successfully with a SHA-1 object id or the value of a symbolic ref |
Example Code:
let currentCommit = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })
console.log(currentCommit)
let currentBranch = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD', depth: 2 })
console.log(currentBranch)
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')