Skip to content

require('path').Repo.open(...) returns {} #241

Closed

Description

@joshjung

Here is sample code of what I'm doing:

var path = require('path');

var GitService = function () {
  this.open = require("nodegit").Repo.open;
};

GitService.prototype = {
  log: function (repo, count, callback) {
   this.open('/home/joshua/skyduel/.git', function(error, repo) {
      if (error) throw error;
      console.log('repo opened', repo);
    });
  }
};

module.exports = GitService;

Console output when I run my wrapper application:

repo opened {}

Any ideas? I know for sure that the repo being requested exists, is freshly populated, and I can do git status on it and receive proper information.

Here is console output showing the git repo is properly initialized:

joshua@joshua-VirtualBox:~/skyduel$ pwd
/home/joshua/skyduel
joshua@joshua-VirtualBox:~/skyduel$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean
joshua@joshua-VirtualBox:~/skyduel$ npm list -g | grep nodegit
├─┬ nodegit@0.1.4
joshua@joshua-VirtualBox:~/skyduel$ 

nodegit@0.1.4

Activity

  1. tbranyen commented on Oct 14, 2014

    @tbranyen
    Member

    This isn't an error, it's returning you a repo Object. You would log repo.__proto__ to see its available methods.

  2. joshjung commented on Oct 14, 2014

    @joshjung
    Author

    Thanks for responding so quickly! I'm rather confused then. There is no 'Repository' object or even a 'Repo.open' method but the Readme.md for the nodegit project states there should be? Am I viewing an old Readme?

    this.open = require("nodegit").Repository.open;
                                               ^
    TypeError: Cannot read property 'open' of undefined
    at Object.GitService (/media/sf_dev/node/pomelo/skyduel/game-server/GitService.js:4:48)
    at Object.<anonymous> (/media/sf_dev/node/pomelo/skyduel/game-server/app.js:8:16)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3
    

    Also, did the promise library get removed? I'm trying to follow examples with '.then()' but they are causing issues.saying I need to provide a callback function instead.

  3. tbranyen commented on Oct 14, 2014

    @tbranyen
    Member

    My guess is that NodeGit isn't installed correctly. Are you running master, the docs are for the current master branch.

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