My test set-up:
const PUBLIC_KEY = fs.readFileSync(`${os.homedir()}/.ssh/id_rsa.pub`, 'utf-8');
const PRIVATE_KEY = fs.readFileSync(`${os.homedir()}/.ssh/id_rsa`, 'utf-8');
/**
* @param {string} environmentName
* @param {Git.Remote} remote
*
* @return {PromiseLike<Number> | Promise<Number>}
*/
const deployToEnvironment = (environmentName, remote) => Git.Cred.sshKeyMemoryNew(USERNAME, PUBLIC_KEY, PRIVATE_KEY, '').then((cred) => {
return remote.push(
[`refs/heads/${environmentName}:refs/heads/platformsh/${environmentName}`],
{
callbacks: {
certificateCheck: () => 0,
credentials: (url, userName) => {
console.log(`getting creds for url:${url} username:${userName}`);
return cred;
},
transferProgress: (progress) => {
console.log('progess: ', progress); // <- never executed
}
}
},
console.log // <- never executed
).catch(console.log).then(console.log); // <- never executed
});
This gives me the following output:
getting creds for url:THE_URL username:THE_USERNAME
However, neither the .catch, nor the .then is called. The push itself does not start.
Additionally, if I run:
$ git push REMOTENAME refs/heads/feature-123:refs/heads/feature-123
I get the following error: error: src refspec refs/head/feature-123 does not match any.
However, doing $ git push REMOTENAME feature-123:refs/heads/feature-123 works like a charm.
So I then tested:
remote.push([${environmentName}:refs/heads/platformsh/${environmentName}], ...) but this yields { Error: no such reference 'feature-123' errno: -1, errorFunction: 'Remote.push' }
transferProgress is for the downloading of data. You need to use pushTransferProgress although that is currently unimplemented. See #1500.
As to why your push isn't working, I have no idea. Perhaps you can check the example and see if that works for you for starters.
Given I'm on windows, I can't use the example (due to the ssh agent). However using the "Git.Cred.sshKeyMemoryNew(username, PUBLIC_KEY, PRIVATE_KEY, '')" instead yields the exact same issue
I tested cloning, this works. pulling also. It's simply the push that is never finishing
At the very least, for your example, your console.log will never be called because we don't implement the callback pattern, it's a promise:
https://github.com/nodegit/nodegit/blob/master/lib/remote.js#L86
I am having the same issue, when I console log out it repeats Credentials being added, to Push Call 100's of times and eventually dies.
const remote = await repo.getRemote('origin');
return remote.push(
['refs/heads/master:refs/heads/master'],
{
callbacks: {
credentials: () => {
console.log('Credentials being added, to Push Call');
return nodegit.Cred.userpassPlaintextNew(token, 'x-oauth-basic');
},
certificateCheck: () => {
return 1;
}
}
}
);
Most helpful comment
I am having the same issue, when I console log out it repeats
Credentials being added, to Push Call100's of times and eventually dies.