@@ -322,8 +322,8 @@ describe("Tag", function() {
322
322
it (
323
323
"can create a tag with a signature and extract the signature" ,
324
324
function ( ) {
325
- const targetOid = Oid . fromString ( commitPointedTo ) ;
326
- const otherTargetOid = Oid . fromString ( commitPointedTo2 ) ;
325
+ var targetCommit ;
326
+ var otherTargetCommit ;
327
327
const name = "created-signed-tag-annotationCreate" ;
328
328
const repository = this . repository ;
329
329
const signature = Signature . create (
@@ -359,14 +359,19 @@ describe("Tag", function() {
359
359
let oid ;
360
360
let object ;
361
361
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 ) => {
364
369
odb = odbResult ;
365
370
366
371
return Tag . createWithSignature (
367
372
repository ,
368
373
name ,
369
- targetOid ,
374
+ targetCommit ,
370
375
signature ,
371
376
message ,
372
377
1 ,
@@ -409,7 +414,7 @@ describe("Tag", function() {
409
414
return Tag . createWithSignature (
410
415
repository ,
411
416
name ,
412
- targetOid ,
417
+ targetCommit ,
413
418
signature ,
414
419
message ,
415
420
1 ,
@@ -421,7 +426,7 @@ describe("Tag", function() {
421
426
return Tag . createWithSignature (
422
427
repository ,
423
428
name ,
424
- otherTargetOid ,
429
+ otherTargetCommit ,
425
430
signature ,
426
431
message ,
427
432
0 ,
@@ -442,8 +447,8 @@ describe("Tag", function() {
442
447
) ;
443
448
444
449
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 ;
447
452
const name = "created-signed-tag-annotationCreate" ;
448
453
const repository = this . repository ;
449
454
const signature = Signature . create (
@@ -461,14 +466,19 @@ describe("Tag", function() {
461
466
let oid ;
462
467
let object ;
463
468
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 ) => {
466
476
odb = odbResult ;
467
477
468
478
return Tag . createWithSignature (
469
479
repository ,
470
480
name ,
471
- targetOid ,
481
+ targetCommit ,
472
482
signature ,
473
483
message ,
474
484
1 ,
@@ -514,7 +524,7 @@ describe("Tag", function() {
514
524
return Tag . createWithSignature (
515
525
repository ,
516
526
name ,
517
- targetOid ,
527
+ targetCommit ,
518
528
signature ,
519
529
message ,
520
530
1 ,
@@ -526,7 +536,7 @@ describe("Tag", function() {
526
536
return Tag . createWithSignature (
527
537
repository ,
528
538
name ,
529
- otherTargetOid ,
539
+ otherTargetCommit ,
530
540
signature ,
531
541
message ,
532
542
0 ,
@@ -544,7 +554,7 @@ describe("Tag", function() {
544
554
} ) ;
545
555
546
556
it ( "will throw if signing callback returns an error code" , function ( ) {
547
- const targetOid = Oid . fromString ( commitPointedTo ) ;
557
+ var targetCommit ;
548
558
const name = "created-signed-tag-annotationCreate" ;
549
559
const repository = this . repository ;
550
560
const signature = Signature . create (
@@ -559,16 +569,18 @@ describe("Tag", function() {
559
569
} ) ;
560
570
561
571
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 ( ) {
572
584
assert . fail ( "Should not have been able to create tag" ) ;
573
585
} , function ( error ) {
574
586
if ( error && error . errno === NodeGit . Error . CODE . ERROR ) {
@@ -579,16 +591,54 @@ describe("Tag", function() {
579
591
} ) ;
580
592
} ) ;
581
593
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
+ } ) ;
582
630
583
631
it ( "can create a new signed tag with Tag.annotationCreate" , function ( ) {
584
- var oid = Oid . fromString ( commitPointedTo ) ;
632
+ var targetCommit ;
585
633
var name = "created-signed-tag-annotationCreate" ;
586
634
var repository = this . repository ;
587
635
var signature = null ;
588
636
var odb = null ;
589
637
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 ) {
592
642
signature = signatureResult ;
593
643
return repository . odb ( ) ;
594
644
} )
@@ -597,7 +647,7 @@ describe("Tag", function() {
597
647
} )
598
648
. then ( function ( ) {
599
649
return Tag . annotationCreate (
600
- repository , name , oid , signature , tagMessage ) ;
650
+ repository , name , targetCommit , signature , tagMessage ) ;
601
651
} )
602
652
. then ( function ( oid ) {
603
653
return odb . read ( oid ) ;
0 commit comments