Hi there,
I think that I've found a bug because Nodegit.Reset.reset(this.repo, headCommit, Nodegit.Reset.TYPE.HARD); returns undefined for me, according the spec it should return a code error. Could someone look on it?
Thanks for this lib, you did a great job! 馃挭
Example:
async reset() {
await this.repo.fetchAll({
callbacks: {
credentials(_, userName) {
return git.Cred.sshKeyNew(
userName,
'/Users/xxx/.ssh/id_rsa.pub',
'/Users/xxx/.ssh/id_rsa',
''
);
},
},
});
const headCommit = await this.repo.getHeadCommit();
return git.Reset.reset(this.repo, headCommit, git.Reset.TYPE.HARD);
}
@jukben This issue is prevalent in a lot of NodeGit's functions. If there is an error the promise will be rejected.
Given the generated code below, you can assume that an error code of zero will resolve to undefined in the promise instead of a value of 0.
void GitReset::ResetWorker::HandleOKCallback() {
if (baton->error_code == GIT_OK) {
v8::Local<v8::Value> result = Nan::Undefined();
v8::Local<v8::Value> argv[2] = {
Nan::Null(),
result
};
callback->Call(2, argv);
} else {
Great - that info saved my life.. 馃槅
馃 I'd propose a fix for the documentation. Unfortunately i'm not able to build it. 馃槥
Most helpful comment
@jukben This issue is prevalent in a lot of NodeGit's functions. If there is an error the promise will be rejected.
Given the generated code below, you can assume that an error code of zero will resolve to
undefinedin the promise instead of a value of0.