Reading Git config variable using NodeGit
Asked Answered
G

2

6

NodeGit does not seem to be providing any API to retrieve Git configuration values.

See http://www.nodegit.org/#Config

I was expecting something like Config#getValue() or similar API to retrieve configuration values.

Perhaps, it is missing in NodeGit as of now, since libgit2 has those APIs.

Any hints?

Grania answered 2/3, 2015 at 9:31 Comment(0)
S
1

NodeGit currently doesn't expose the config functionality of libgit2. That shouldn't be too hard to get in there but I don't know if it'll make into the 0.3.0 release that is scheduled for the next release.

I created an issue that you can track if you want updates on the progress of it.

Sheffie answered 2/3, 2015 at 15:23 Comment(0)
S
1

Here's an example to get a global git config variable:

var nodegit = require("nodegit");

nodegit.Config.openDefault()
  .then(function (config) {
    return config.getStringBuf('user.name');
  })
  .then(console.log);

and here's how to get a repository's config variable:

nodegit.Repository.open('PATH_TO_REPO')
  .then(function (repository) {
    return repository.config();
  })
  .then(function (config) {
    return config.getStringBuf('user.name');
  })
  .then(console.log);
Shied answered 12/5, 2018 at 10:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.