@@ -322,8 +322,8 @@ describe("Tag", function() {
322322 it (
323323 "can create a tag with a signature and extract the signature" ,
324324 function ( ) {
325- const targetOid = Oid . fromString ( commitPointedTo ) ;
326- const otherTargetOid = Oid . fromString ( commitPointedTo2 ) ;
325+ var targetCommit ;
326+ var otherTargetCommit ;
327327 const name = "created-signed-tag-annotationCreate" ;
328328 const repository = this . repository ;
329329 const signature = Signature . create (
@@ -359,14 +359,19 @@ describe("Tag", function() {
359359 let oid ;
360360 let object ;
361361
362- return repository . odb ( )
363- . then ( ( odbResult ) => {
362+ return repository . getCommit ( commitPointedTo ) . then ( ( commit ) => {
363+ targetCommit = commit ;
364+ return repository . getCommit ( commitPointedTo2 ) ;
365+ } ) . then ( ( commit ) => {
366+ otherTargetCommit = commit ;
367+ return repository . odb ( ) ;
368+ } ) . then ( ( odbResult ) => {
364369 odb = odbResult ;
365370
366371 return Tag . createWithSignature (
367372 repository ,
368373 name ,
369- targetOid ,
374+ targetCommit ,
370375 signature ,
371376 message ,
372377 1 ,
@@ -409,7 +414,7 @@ describe("Tag", function() {
409414 return Tag . createWithSignature (
410415 repository ,
411416 name ,
412- targetOid ,
417+ targetCommit ,
413418 signature ,
414419 message ,
415420 1 ,
@@ -421,7 +426,7 @@ describe("Tag", function() {
421426 return Tag . createWithSignature (
422427 repository ,
423428 name ,
424- otherTargetOid ,
429+ otherTargetCommit ,
425430 signature ,
426431 message ,
427432 0 ,
@@ -442,8 +447,8 @@ describe("Tag", function() {
442447 ) ;
443448
444449 it ( "can optionally skip the signing process" , function ( ) {
445- const targetOid = Oid . fromString ( commitPointedTo ) ;
446- const otherTargetOid = Oid . fromString ( commitPointedTo2 ) ;
450+ var targetCommit ;
451+ var otherTargetCommit ;
447452 const name = "created-signed-tag-annotationCreate" ;
448453 const repository = this . repository ;
449454 const signature = Signature . create (
@@ -461,14 +466,19 @@ describe("Tag", function() {
461466 let oid ;
462467 let object ;
463468
464- return repository . odb ( )
465- . then ( ( odbResult ) => {
469+ return repository . getCommit ( commitPointedTo ) . then ( ( commit ) => {
470+ targetCommit = commit ;
471+ return repository . getCommit ( commitPointedTo2 ) ;
472+ } ) . then ( ( commit ) => {
473+ otherTargetCommit = commit ;
474+ return repository . odb ( ) ;
475+ } ) . then ( ( odbResult ) => {
466476 odb = odbResult ;
467477
468478 return Tag . createWithSignature (
469479 repository ,
470480 name ,
471- targetOid ,
481+ targetCommit ,
472482 signature ,
473483 message ,
474484 1 ,
@@ -514,7 +524,7 @@ describe("Tag", function() {
514524 return Tag . createWithSignature (
515525 repository ,
516526 name ,
517- targetOid ,
527+ targetCommit ,
518528 signature ,
519529 message ,
520530 1 ,
@@ -526,7 +536,7 @@ describe("Tag", function() {
526536 return Tag . createWithSignature (
527537 repository ,
528538 name ,
529- otherTargetOid ,
539+ otherTargetCommit ,
530540 signature ,
531541 message ,
532542 0 ,
@@ -544,7 +554,7 @@ describe("Tag", function() {
544554 } ) ;
545555
546556 it ( "will throw if signing callback returns an error code" , function ( ) {
547- const targetOid = Oid . fromString ( commitPointedTo ) ;
557+ var targetCommit ;
548558 const name = "created-signed-tag-annotationCreate" ;
549559 const repository = this . repository ;
550560 const signature = Signature . create (
@@ -559,16 +569,18 @@ describe("Tag", function() {
559569 } ) ;
560570
561571
562- return Tag . createWithSignature (
563- repository ,
564- name ,
565- targetOid ,
566- signature ,
567- message ,
568- 1 ,
569- signingCallback
570- )
571- . then ( function ( ) {
572+ return repository . getCommit ( commitPointedTo ) . then ( ( commit ) => {
573+ targetCommit = commit ;
574+ return Tag . createWithSignature (
575+ repository ,
576+ name ,
577+ targetCommit ,
578+ signature ,
579+ message ,
580+ 1 ,
581+ signingCallback
582+ ) ;
583+ } ) . then ( function ( ) {
572584 assert . fail ( "Should not have been able to create tag" ) ;
573585 } , function ( error ) {
574586 if ( error && error . errno === NodeGit . Error . CODE . ERROR ) {
@@ -579,16 +591,54 @@ describe("Tag", function() {
579591 } ) ;
580592 } ) ;
581593
594+ it ( "will show a deprecation warning if createWithSignature use oid instead object" , function ( ) {
595+ var targetCommit ;
596+ const name = "created-signed-tag-annotationCreate" ;
597+ const repository = this . repository ;
598+ const signature = Signature . create (
599+ "Shaggy Rogers" ,
600+ 601+ 987654321 ,
602+ 90
603+ ) ;
604+ const message = "I'm a teapot" ;
605+ const signingCallback = ( ) => ( {
606+ code : NodeGit . Error . CODE . ERROR
607+ } ) ;
608+
609+
610+ return repository . getCommit ( commitPointedTo ) . then ( ( commit ) => {
611+ targetCommit = commit ;
612+ return Tag . createWithSignature (
613+ repository ,
614+ name ,
615+ targetCommit . id ( ) ,
616+ signature ,
617+ message ,
618+ 1 ,
619+ signingCallback
620+ ) ;
621+ } ) . then ( function ( ) {
622+ assert . fail ( "Should not have been able to create tag" ) ;
623+ } , function ( error ) {
624+ if ( error && error . errno === NodeGit . Error . CODE . ERROR ) {
625+ return ;
626+ }
627+ throw error ;
628+ } ) ;
629+ } ) ;
582630
583631 it ( "can create a new signed tag with Tag.annotationCreate" , function ( ) {
584- var oid = Oid . fromString ( commitPointedTo ) ;
632+ var targetCommit ;
585633 var name = "created-signed-tag-annotationCreate" ;
586634 var repository = this . repository ;
587635 var signature = null ;
588636 var odb = null ;
589637
590- return Signature . default ( repository )
591- . then ( function ( signatureResult ) {
638+ return repository . getCommit ( commitPointedTo ) . then ( ( commit ) => {
639+ targetCommit = commit ;
640+ return Signature . default ( repository ) ;
641+ } ) . then ( function ( signatureResult ) {
592642 signature = signatureResult ;
593643 return repository . odb ( ) ;
594644 } )
@@ -597,7 +647,7 @@ describe("Tag", function() {
597647 } )
598648 . then ( function ( ) {
599649 return Tag . annotationCreate (
600- repository , name , oid , signature , tagMessage ) ;
650+ repository , name , targetCommit , signature , tagMessage ) ;
601651 } )
602652 . then ( function ( oid ) {
603653 return odb . read ( oid ) ;
0 commit comments