FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

getStatus hangs · Issue #537 · nodegit/nodegit · GitHub

Repository navigation

getStatus hangs #537

Description

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 to ctrl+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 remove getStatus() entirely, so this seems to originate in the getStatus() 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?

Activity

tbranyen commented on Apr 11, 2015

Member

Looks to be a duplicate of: #497

AdamStone commented on Apr 11, 2015

Author

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.

tommoor commented on Dec 7, 2016

I'm still seeing this behavior in the latest 0.16 release - getStatus does not resolve sporadically - trying to dig into what might be causing this for us :(

heath-guidewire commented on Apr 6, 2017

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

tommoor commented on Apr 6, 2017

@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…

heath-guidewire commented on Apr 6, 2017

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.

tommoor commented on Apr 6, 2017

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;
})
  

heath-guidewire commented on Apr 6, 2017

Hmm, even that command seems to have the same issue... Sometimes it works and sometimes it doesn't.

tommoor commented on Apr 6, 2017

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.

heath-guidewire commented on Apr 6, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL