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 Answers 2

4

According to the new APIs from [email protected]

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();
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.