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:
- the url from the remote repository (Ex: https://github.com/nodegit/nodegit/)
Is it possible?
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?
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();
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());
})
})
});