2

i'm using the nodegit library to get all commits from my repository, and i want to get general information from the local repository as for example:

Is it possible?

2 Answers2

4

According to the new APIs from NodeGit@0.26.1

export const getRemoteUrl = async (path, remoteName) => {
    try {
        const repository = await nodegit.Repository.open(path);
        const remote = await repository.getRemote(remoteName); // e.g. "origin"
        return await remote.url();
    } catch (error) {
        console.log(error);
    }
};

// To use the above function within another async function:
const remoteUrl = await getRemoteUrl();
Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
Yashu Mittal
  • 1,478
  • 3
  • 14
  • 32
3

It is almost the same as you would do in git:

nodegit.Repository.open(".git").then(repo => {
    repo.config().then(config => {
        config.getStringBuf("remote.origin.url").then(buf => {
            console.log(buf.toString());
        })
    })
});
Xiaoy312
  • 14,292
  • 1
  • 32
  • 44