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
{{ message }}
Repository navigation
Missing example: commit to a local repo (i.e. git add, git commit) #96
I haven't tested any index-related functions, so I'm not sure if this is supported yet. If you have time I'd love for you to help -- I can walk you through how to add this functionality yourself, it's (hopefully) pretty easy.
First, if you can research which raw C libgit2 functions would need to be available to do this functionality. Next, find each of these in the v0.18.json file in root directory of nodegit. If you can copy and paste those here, I'll show you how to make those available to javascript-land.
ok so I played more with it and I can add and commit a file like so: (assuming repo is the opened repo, file is the filename to be committed, Q and QFS are q.js and q-io.js)
varmsg=file+' updated by John Doe';varauthor=git.Signature.now("John Doe",'jdoe@example.com');returnQFS.write(QFS.join(repo.workdir(),file),content).then(function(){returnQ.ninvoke(repo,'openIndex')}).then(function(index){logger.debug('openIndex');returnQ.ninvoke(index,'read').then(function(){logger.debug('read');returnQ.ninvoke(index,'addByPath',file);}).then(function(){logger.debug('addByPath');returnQ.ninvoke(index,'write');}).then(function(){logger.debug('write');returnQ.ninvoke(index,'writeTree');});}).then(function(oid){logger.debug('writeTree',oid);returnQ.nfcall(git.Reference.oidForName,repo,'HEAD').then(function(head){logger.debug('oidForName',head);returnQ.ninvoke(repo,'getCommit',head);}).then(function(commit){logger.debug('getCommit',commit);returnQ.ninvoke(repo,'createCommit','HEAD',author,author,msg,oid,[commit]);});}).then(function(newCommit){varsha=newCommit.sha();logger.info(msg+' (commit '+sha+')');returnsha;});
Special request. Can you turn this into an example to put in the examples directory? Could you remove the dependency on Q for the sake of the example -- just add in the usual callback junk. Call it "add-and-commit.js" or something?
Special request. Can you turn this into an example to put in the examples directory? Could you remove the dependency on Q for the sake of the example -- just add in the usual callback junk. Call it "add-and-commit.js" or something?
—
Reply to this email directly or view it on GitHub.
Activity
nkallen commentedon Sep 28, 2013
I haven't tested any index-related functions, so I'm not sure if this is supported yet. If you have time I'd love for you to help -- I can walk you through how to add this functionality yourself, it's (hopefully) pretty easy.
First, if you can research which raw C libgit2 functions would need to be available to do this functionality. Next, find each of these in the v0.18.json file in root directory of nodegit. If you can copy and paste those here, I'll show you how to make those available to javascript-land.
dcolens commentedon Sep 30, 2013
ok so I played more with it and I can add and commit a file like so: (assuming repo is the opened repo, file is the filename to be committed, Q and QFS are q.js and q-io.js)
nkallen commentedon Oct 1, 2013
Hey,
Special request. Can you turn this into an example to put in the examples directory? Could you remove the dependency on Q for the sake of the example -- just add in the usual callback junk. Call it "add-and-commit.js" or something?
dcolens commentedon Oct 2, 2013
Will do that
thanks for your support
Did
On 01 Oct 2013, at 19:32, Nick Kallen notifications@github.com wrote: