@@ -128,12 +128,14 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) {
128128 // parents. Here we're creating oid objects to create the commit with,
129129 // but you can also use existing ones:
130130
131- var treeId = git . Oid . fromString ( "28873d96b4e8f4e33ea30f4c682fd325f7ba56ac " ) ;
132- var parentId = git . Oid . fromString ( "f0877d0b841d75172ec404fc9370173dfffc20d1 " ) ;
131+ var treeId = git . Oid . fromString ( "4170d10f19600b9cb086504e8e05fe7d863358a2 " ) ;
132+ var parentId = git . Oid . fromString ( "eebd0ead15d62eaf0ba276da53af43bbc3ce43ab " ) ;
133133
134134 repo . getTree ( treeId , function ( error , tree ) {
135+ if ( error ) throw error ;
136+
135137 repo . getCommit ( parentId , function ( error , parent ) {
136- return "Not yet working!" ;
138+ if ( error ) throw error ;
137139 // Here we actually create the commit object with a single call with all
138140 // the values we need to create the commit. The SHA key is written to the
139141 // `commit_id` variable here.
@@ -144,8 +146,8 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) {
144146 "example commit" ,
145147 tree ,
146148 [ parent ] ,
147- function ( error , commitOid ) {
148- console . log ( "New Commit:" , commitOid . sha ( ) ) ;
149+ function ( error , oid ) {
150+ console . log ( "New Commit:" , oid . sha ( ) ) ;
149151 } ) ;
150152 } ) ;
151153 } ) ;
@@ -306,16 +308,19 @@ git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) {
306308 // references such as branches, tags and remote references (everything in
307309 // the .git/refs directory).
308310
309- return "this doesn't yet work" ;
310- repo . getReferences ( function ( error , references ) {
311+ repo . getReferences ( git . Reference . Type . Oid | git . Reference . Type . Symbolic , function ( error , referenceNames ) {
311312 if ( error ) throw error ;
312313
313- references . forEach ( function ( reference ) {
314- if ( reference . type ( ) == git . Reference . Oid ) {
315- console . log ( oid . sha ( ) ) ;
316- } else if ( reference . type ( ) == git . Reference . Symbolic ) {
317- console . log ( reference . symbolicTarget ( ) ) ;
318- }
314+ referenceNames . forEach ( function ( referenceName ) {
315+ repo . getReference ( referenceName , function ( error , reference ) {
316+ if ( error ) throw error ;
317+
318+ if ( reference . isOid ( ) ) {
319+ console . log ( "Reference:" , referenceName , reference . oid ( ) ) ;
320+ } else if ( reference . isSymbolic ( ) ) {
321+ console . log ( "Reference:" , referenceName , reference . symbolicTarget ( ) ) ;
322+ }
323+ } ) ;
319324 } ) ;
320325 } ) ;
321326} ) ;
0 commit comments