nodegit | Native Node bindings to Git | Runtime Evironment library
kandi X-RAY | nodegit Summary
kandi X-RAY | nodegit Summary
Node bindings to the libgit2 project.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nodegit
nodegit Key Features
nodegit Examples and Code Snippets
var nodegit = require("nodegit");
var path = require("path");
var fse = require("fs-extra");
var repoDir = "../git_repositories/";
var repository;
var index;
//eventually need to pass in user here for some metadata (author/committor info
Community Discussions
Trending Discussions on nodegit
QUESTION
What is the equivalent way of executing git clone --recurse-submodules git@myrepo.git
with NodeGit?
I've found some manual examples of how to do it but they're quite old and I'm hoping there's a native way to do it now.
...ANSWER
Answered 2021-Apr-02 at 15:55There's no way to do this with nodegit natively because it's not supported by the underlying library, libgit2
: https://github.com/nodegit/nodegit/issues/1233#issuecomment-809717805
QUESTION
Due to different node versions and different ABI incompatibilities I need to load a C++ addon relatively because they are located with different ABI versions at different locations.
But the issue I am having is even simpler explained. Why do the 2 following calls differ?
...ANSWER
Answered 2020-Nov-14 at 00:04- "nodegit" is the package main entry point
- "./../path/to/nodegit.node" the native extension alone
QUESTION
I write an Electron app that uses nodegit. For my test part I use ava in combination with Spectron to test my app. All of my tests work - including functions which use nodegit in my app.
In addition to the tests described above I made also a pure non-Electron test file in which I import nodegit directly.
...ANSWER
Answered 2020-Nov-14 at 14:01Hey) I think I can solve your problem, just try this:
QUESTION
I use Clone.clone from nodegit
and I am looking for a progress status callback. The function has a CheckoutOptions object, which I call like this:
ANSWER
Answered 2020-Sep-25 at 21:19Try initializing the checkout options using new CheckoutOptions()
instead of using just an empty object {}
.
This version works:
QUESTION
I installed nodegit 0.26.5
via npm
and import the package in the renderer part of my Electron application. During compilation I receive this error below:
ANSWER
Answered 2020-Sep-10 at 10:57I'm using nodegit 0.27
and the error message for me was slightly different, it was
QUESTION
var nodegit = require("nodegit");
var path = require("path");
var fse = require("fs-extra");
var repoDir = "../git_repositories/";
var repository;
var index;
//eventually need to pass in user here for some metadata (author/committor info)
createGitRepository = (user, repositoryName) => {
var newRepoDir = repoDir.concat(repositoryName);
var fileName = repositoryName.concat(".txt");
var fileContent = repositoryName.concat("DEFAULT CONTENTS");
fse.ensureDir(path.resolve(__dirname, newRepoDir))
.then(function () {
return nodegit.Repository.init(path.resolve(__dirname, newRepoDir), 0);
})
.then(function (repo) {
repository = repo;
return fse.writeFile(path.join(repository.workdir(), fileName), fileContent);
})
.then(function () {
return repository.refreshIndex();
})
.then(function (idx) {
index = idx;
})
.then(function () {
return index.addByPath(fileName);
})
.then(function () {
return index.write();
})
.then(function () {
return index.writeTree();
})
.then(function (oid) {
var author = nodegit.Signature.now("Zaphod Beeblebrox",
"zaphod@gmail.com");
var committer = nodegit.Signature.now("Ford Prefect",
"ford@github.com");
// Since we're creating an inital commit, it has no parents. Note that unlike
// normal we don't get the head either, because there isn't one yet.
var commit = repository.createCommit("HEAD", author, committer, "message", oid, []);
return commit;
})
.done(function (commitId) {
console.log("New Commit: ", commitId);
});
}
addAndCommit = (fileName, fileContent) => {
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
.then(function (repoResult) {
repo = repoResult;
return fse.ensureDir(path.join(repo.workdir(), directoryName));
}).then(function () {
return fse.writeFile(path.join(repo.workdir(), fileName), fileContent);
})
.then(function () {
return fse.writeFile(
path.join(repo.workdir(), directoryName, fileName),
fileContent
);
})
.then(function () {
return repo.refreshIndex();
})
.then(function (indexResult) {
index = indexResult;
})
.then(function () {
// this file is in the root of the directory and doesn't need a full path
return index.addByPath(fileName);
})
.then(function () {
// this file is in a subdirectory and can use a relative path
return index.addByPath(path.posix.join(directoryName, fileName));
})
.then(function () {
// this will write both files to the index
return index.write();
})
.then(function () {
return index.writeTree();
})
.then(function (oidResult) {
oid = oidResult;
return nodegit.Reference.nameToId(repo, "HEAD");
})
.then(function (head) {
return repo.getCommit(head);
})
.then(function (parent) {
var author = nodegit.Signature.now("Scott Chacon",
"schacon@gmail.com");
var committer = nodegit.Signature.now("Scott A Chacon",
"scott@github.com");
return repo.createCommit("HEAD", author, committer, "message", oid, [parent]);
})
.done(function (commitId) {
console.log("New Commit: ", commitId);
});
}
module.exports = {
createGitRepository,
addAndCommit
}
...ANSWER
Answered 2020-Sep-09 at 02:25needed to change .done to .then at the end
QUESTION
I'm developing my first package for Atom. To do it, I need this package nodegit
(here the official website).
When I try to run my package, I get this error:
...ANSWER
Answered 2020-Feb-29 at 12:05You need to use electron-rebuild for this.
From the README:
This executable rebuilds native Node.js modules against the version of Node.js that your Electron project is using. This allows you to use native Node.js modules in Electron apps without your system version of Node.js matching exactly (which is often not the case, and sometimes not even possible).
QUESTION
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?
...ANSWER
Answered 2018-Jul-18 at 15:01It is almost the same as you would do in git:
QUESTION
I need a reliable way to clone a github repo and paste it into a local directory using node.js and any necessary npm packages.
This code is using the nodegit library and doesn't work to clone a github repo. it creates a single folder named .git and copies none of the files from the repo. I have tried several libraries most of which have extremely complicated code or don't work. This was working before but now isn't. (it goes on and off as it pleases). pls help, I need a reliable code that clones a github repo from url and pastes it into a local directory. Thank you.
...ANSWER
Answered 2019-Aug-27 at 06:57Try the npm Package
https://www.npmjs.com/package/git-clone
npm i git-clone
var clone = require('git-clone');
clone(repo, targetPath, [options], cb);
Supported options:
git: path to git binary; default: git (optional).
shallow: when true, clone with depth 1 (optional).
checkout: revision/branch/tag to check out (optional).
QUESTION
I am attempting to write a fairly simple nodejs program that needs to clone a git repo.
...ANSWER
Answered 2019-Jan-03 at 16:49I solved this. It is related to the version of git for windows (2.19.1) that I was running, and updating to the newest version removed the error.
I eventually found the right search term combination that lead me to this bug: https://github.com/git-for-windows/git/issues/1868
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nodegit
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page