You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Index.entryCount() does not return the number of staged files, rather the total number of files checked in at the current index. To get the number of staged changes you can use:
constrepo=awaitRepository.open(repoPath);constindex=awaitrepo.refreshIndex();constflags: Diff.OPTION=Diff.OPTION.IGNORE_WHITESPACE;// not needed, can be 0consthead=awaitrepo.getHeadCommit();// In an "empty" repository the `oldTree` parameter (here `await head.getTree()`) must be `undefined`.conststagedDiff=awaitDiff.treeToIndex(repo,awaithead.getTree(),index,{ flags });constnumberOfStagedChanges=stagedDiff.numDeltas();
And to get the files which are changed, but not yet staged, could be something like:
System information
trying to get number of files to avoid empty commits using entryCount(), but it is returning a number > 0 even if there is no file to commit
SO https://stackoverflow.com/questions/75755796/nodegit-avoid-creating-empty-commit-nodejs-bitbucket
any help?
The text was updated successfully, but these errors were encountered: