status
Tell whether a file has been changed
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 |
filepath | string | The path to the file to query |
cache | object | a cache object |
return | Promise<('ignored' | 'unmodified' | 'modified' | 'deleted' | 'added' | 'absent' | 'modified' | 'deleted' | 'added' | 'unmodified' | 'absent' | 'undeleted' | '*undeletemodified')> | Resolves successfully with the file's git status |
The possible resolve values are:
status | description |
---|---|
"ignored" | file ignored by a .gitignore rule |
"unmodified" | file unchanged from HEAD commit |
"*modified" | file has modifications, not yet staged |
"*deleted" | file has been removed, but the removal is not yet staged |
"*added" | file is untracked, not yet staged |
"absent" | file not present in HEAD commit, staging area, or working dir |
"modified" | file has modifications, staged |
"deleted" | file has been removed, staged |
"added" | previously untracked file, staged |
"*unmodified" | working dir and HEAD commit match, but index differs |
"*absent" | file not present in working dir or HEAD commit, but present in the index |
"*undeleted" | file was deleted from the index, but is still in the working dir |
"*undeletemodified" | file was deleted from the index, but is present with modifications in the working dir |
Example Code:
let status = await git.status({ fs, dir: '/tutorial', filepath: 'README.md' })
console.log(status)
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')