Edit: I'm changing the question to suit my current understanding of the problem which has changed significantly.
Original Title: Nodegit seems to be asking for wrong credentials on push
When trying to push
using nodegit nothing seems to work on Windows (while they work fine on Linux).
- Using SSH
sshKeyFromAgent
- error authenticating: failed connecting agentsshKeyNew
-credentials
callback is repeatedly (looks like an infinite loop but I can't be sure)sshKeyMemoryNew
:credentials
is called twice and then node exits with no diagnostic (theexit
andbeforeExit
events onprocess
aren't signalled)
- Using HTTPS
userpassPlaintextNew
: [Error: unknown certificate check failure] errno: -17
Original question follows.
I'm trying to get nodegit
to push
and the following question seems to address this situation. However I'm not able to get it to work.
I've cloned a repository using SSH and when I try to push, my credentials
callback is being called with user git and not motti (which is the actual git user).
try {
const remote = await repository.getRemote("origin");
await remote.push(["refs/head/master:refs/heads/master"], {
callbacks: {
credentials: (url, user) => {
console.log(`Push asked for credentials for '${user}' on ${url}`);
return git.Cred.sshKeyFromAgent(user);
}
}
});
}
catch(err) {
console.log("Error:", err);
}
I get the following output:
Push asked for credentials for 'git' on git@github.[redacted].net:motti/tmp.git
Error: { Error: error authenticating: failed connecting agent errno: -1, errorFunction: 'Remote.push' }
If I try to hardcode motti to the sshKeyFromAgent
function the error changes to:
Error: { Error: username does not match previous request errno: -1, errorFunction: 'Remote.push' }
This my first time trying to programmatically use git so I may be missing something basic...
Answer for some questions from comments:
- I'm running on windows 10
- node v8.9.4
- git version 2.15.0.windows.1
- nodegit version 0.24.1
- the user running node is my primary user which when I use for git in command line works correctly