X Tutup
The Wayback Machine - https://web.archive.org/web/20200916181422/https://github.com/nodegit/nodegit/pull/1420
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how getReferenceCommit() retrieves commits #1420

Open
wants to merge 1 commit into
base: master
from

Conversation

@rcjsuen
Copy link
Member

rcjsuen commented Dec 26, 2017

The current code in repository.js assumes that the return value from reference.target() is an oid that points to a commit.

nodegit/lib/repository.js

Lines 1057 to 1069 in b6e1478

Repository.prototype.getReferenceCommit = function(name, callback) {
var repository = this;
return this.getReference(name).then(function(reference) {
return repository.getCommit(reference.target()).then(function(commit) {
if (typeof callback === "function") {
callback(null, commit);
}
return commit;
});
}, callback);
};

However, this is not true for annotated commits as its target oid is actually the tag object itself. To get around this, reference.peel(NodeGit.Object.TYPE.COMMIT) should be used instead so that the reference object will fully unwrap itself to the underlying commit object. This should fix #1370.

@rcjsuen rcjsuen force-pushed the rcjsuen:getReferenceCommit branch from ff4062c to 9ff5708 Mar 7, 2018
If a tag is annotated, its target() will return a tag object instead
of the tag's underlying commit. This causes Repository's
getReferenceCommit() to not work as it will try to find a commit
based on the tag's oid. By replacing target() with peel(), the code
can now find the actual underlying commit regardless of whether a tag
is annotated or not.

Signed-off-by: Remy Suen <remy.suen@gmail.com>
@rcjsuen rcjsuen force-pushed the rcjsuen:getReferenceCommit branch from 9ff5708 to 749844b Mar 19, 2018
@implausible implausible force-pushed the nodegit:master branch from c345989 to c67b436 Aug 26, 2019
@implausible implausible force-pushed the nodegit:master branch from 2b7db46 to 69b010a Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

1 participant
You can’t perform that action at this time.
X Tutup