Skip to content

Commit be64459

Browse files
Fix tag createWithSignature function
Also tests fixed
1 parent 1c304e5 commit be64459

File tree

2 files changed

+45
-31
lines changed

2 files changed

+45
-31
lines changed

lib/tag.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Tag.createBuffer = function(repo, tagName, target, tagger, message) {
5353
* @async
5454
* @param {Repository} repo
5555
* @param {String} tagName
56-
* @param {Oid} target
56+
* @param {Object} target
5757
* @param {Signature} tagger
5858
* @param {String} message
5959
* @param {Number} force
@@ -71,7 +71,7 @@ Tag.createWithSignature = function(
7171
signingCallback
7272
) {
7373
let tagBuffer;
74-
return Tag.createBuffer(repo, tagName, target, tagger, message)
74+
return Tag.createBuffer(repo, tagName, target.id(), tagger, message)
7575
.then((tagBufferResult) => {
7676
tagBuffer = tagBufferResult;
7777
return signingCallback(tagBuffer);

test/tests/tag.js

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {
@@ -581,14 +593,16 @@ describe("Tag", function() {
581593

582594

583595
it("can create a new signed tag with Tag.annotationCreate", function() {
584-
var oid = Oid.fromString(commitPointedTo);
596+
var targetCommit;
585597
var name = "created-signed-tag-annotationCreate";
586598
var repository = this.repository;
587599
var signature = null;
588600
var odb = null;
589601

590-
return Signature.default(repository)
591-
.then(function(signatureResult) {
602+
return repository.getCommit(commitPointedTo).then((commit) => {
603+
targetCommit = commit;
604+
return Signature.default(repository);
605+
}).then(function(signatureResult) {
592606
signature = signatureResult;
593607
return repository.odb();
594608
})
@@ -597,7 +611,7 @@ describe("Tag", function() {
597611
})
598612
.then(function() {
599613
return Tag.annotationCreate(
600-
repository, name, oid, signature, tagMessage);
614+
repository, name, targetCommit, signature, tagMessage);
601615
})
602616
.then(function(oid) {
603617
return odb.read(oid);

0 commit comments

Comments
 (0)