Repository navigation
getStatus hangs #537
Description
Activity
Looks to be a duplicate of: #497
D'oh, I tried to search but I guess I was too focused on status/getStatus.
For now I'll just use the workaround from #497 of putting
process.exit()in the.done()method.I'm still seeing this behavior in the latest 0.16 release -
getStatusdoes not resolve sporadically - trying to dig into what might be causing this for us :(I'm still seeing this on 0.18.0. The first call to this method in my tests returns, the next one does not return and the .then() is not executed... same for any subsequent calls. It's almost like the first call leaves something in the thread that prevents any others from properly returning the promise
@heath-guidewire we ended up completely removing use of getStatus from our code, instead diffing the index to working tree using
NodeGit.Diff. Maybe that's a strategy you could take…Is there an example for this? Basically I want to know whether there have been any changes in the repo from the checked out version so that I can determine that I have to create a commit or not.
Not sure about examples, but there is a method for it which works well and provides similar results to getStatus with a bit of massaging http://www.nodegit.org/api/diff/#indexToWorkdir
Something along the lines of:
Git.Diff.indexToWorkdir(repo, null, yourDiffOptions) .then(diff => { const changes = {}; for (let i = 0; i < diff.numDeltas(); i++) { const delta = diff.getDelta(i); const oldPath = delta.oldFile().path(); const newPath = delta.newFile().path(); const statusPath = oldPath || newPath; changes[statusPath] = delta.status(); } return changes; })
Hmm, even that command seems to have the same issue... Sometimes it works and sometimes it doesn't.
We've not seen any issues with that one (across tens of thousands of commits), I'd definitely check the rest of your code thoroughly, sounds like this might not be where your issue lies - most likely an unreturned promise.
I'm seeing a weird issue where repository.refreshIndex() does not return: Here's the code I have
let repository; return nodegit.Repository.open(gitRepoPath()) .then(repo => { repository = repo; console.log('repo opened'); return repository.refreshIndex() .then(index => { console.log('read index', index); const flags = nodegit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | nodegit.Diff.OPTION.RECURSE_UNTRACKED_DIRS; const diffOptions = {flags}; return nodegit.Diff.indexToWorkdir(repository, index, diffOptions) .then(diff => { console.log('changes found', diff); const changes = {}; for (let i = 0; i < diff.numDeltas(); i++) { const delta = diff.getDelta(i); const oldPath = delta.oldFile().path(); const newPath = delta.newFile().path(); const statusPath = oldPath || newPath; changes[statusPath] = delta.status(); } return changes; }) }) });I see the 'repo opened' message, but not the 'read index' message. Funny thing is that another method I have that uses refreshIndex() works. I swear I am totally missing something that's causing it to fail. Even using repository.index() seems to not return either.
I'm trying the status example and finding that if uncommitted changes are present, although the example seems to work (prints
filename MODIFIED), it doesn't return and I have toctrl+C. I tried adding.done()at the end of each promise chain, but nothing gets thrown.This also happens if I remove the details after
getStatus(), but not if I removegetStatus()entirely, so this seems to originate in thegetStatus()call itself. But if the directory is clean, it does return without printing anything.Npm installed
^0.3.3.Anyone know what's going on here?