You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why are you doing this? This prevents reuse, e.g. I want to clone, and then fetch.
letremoteOpts={remoteCallbacks: {certificateCheck: function(){return1;},credentials: function(url,username){returngit.Cred.sshKeyFromAgent(username);}}};functiongetFileFromBranch(branch,filePath){letrepository;returngit.Repository.open(config.git.cloneTo).catch(function(err){if(err.message.startsWith('Failed to resolve')){winston.info('Repo not found, cloning');// USED HEREreturngit.Clone(config.git.repo,config.git.cloneTo,remoteOpts);}else{winston.error(err);throwerr;}}).then(function(repo){repository=repo;winston.log('verbose','Changing branch');returnrepo.checkoutBranch(branch);}).catch(function(err){if(/Reference'([^']+)'notfound/.test(err.message)){winston.info('Branch not found, fetching');// USED HEREletremoteCallbacks=remoteOpts.remoteCallbacks;returnrepository.fetch('origin',remoteCallbacks,true).then(function(){returnrepository.checkoutBranch(branch);});}else{winston.error(err);throwerr;}}).then(function(){returnfs.readFile(path.join(config.git.cloneTo,filePath));});}
@callumacrae ah I see what the issue is. We normalize the entire options object thus overriding the one you passed. I'm not entirely sure why we have the delete there anymore... I'll try removing it and see if the tests still pass.
Activity
tbranyen commentedon Apr 9, 2015
As you can see only a few lines further down, we reattach it with the options normalized:
https://github.com/nodegit/nodegit/blob/master/lib/clone.js#L27-L28
Your code should work just fine. If not please let us know what's broken.
callumacrae commentedon Apr 9, 2015
My code was throwing an error because
remoteOpts.remoteCallbackswas undefined. Not sure why, but it isn't my code!tbranyen commentedon Apr 9, 2015
@callumacrae ah I see what the issue is. We normalize the entire options object thus overriding the one you passed. I'm not entirely sure why we have the
deletethere anymore... I'll try removing it and see if the tests still pass.tbranyen commentedon Apr 9, 2015
Created a PR: #534
tbranyen commentedon Apr 9, 2015
Yup, here is the bug that is introduced by removing the
deletekeyword:https://travis-ci.org/nodegit/nodegit/jobs/57813650#L716
We might be able to work around it tho.
johnhaley81 commentedon Apr 9, 2015
What would we do without tests? We'd break code that's what we'd do!
johnhaley81 commentedon Apr 20, 2015
@tbranyen did you have an idea for a work-around?