Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,10 +1067,8 @@ Repository.prototype.getReference = function(name, callback) {
* @return {Commit}
*/
Repository.prototype.getReferenceCommit = function(name, callback) {
var repository = this;

return this.getReference(name).then(function(reference) {
return repository.getCommit(reference.target()).then(function(commit) {
return reference.peel(NodeGit.Object.TYPE.COMMIT).then(function(commit) {
if (typeof callback === "function") {
callback(null, commit);
}
Expand Down
36 changes: 36 additions & 0 deletions test/tests/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,40 @@ describe("Repository", function() {
assert.equal(numMergeHeads, 1);
});
});

it("can get reference commit that points at lightweight tag", function() {
var repository = this.repository;
var oid = null;
return repository.getHeadCommit()
.then(function(commit) {
oid = commit.id().toString();
return repository.createLightweightTag(
oid, "getReferenceCommitLightweight");
})
.then(function() {
return repository.getReferenceCommit(
"refs/tags/getReferenceCommitLightweight");
})
.then(function(commit) {
assert.equal(commit.id().toString(), oid);
});
});

it("can get reference commit that points at annotated tag", function() {
var repository = this.repository;
var oid = null;
return repository.getHeadCommit()
.then(function(commit) {
oid = commit.id().toString();
return repository.createTag(
oid, "getReferenceCommitAnnotated", "");
})
.then(function() {
return repository.getReferenceCommit(
"refs/tags/getReferenceCommitAnnotated");
})
.then(function(commit) {
assert.equal(commit.id().toString(), oid);
});
});
});