0

Currently, I am listing the files on git tree using:

repository
    .getBranchCommit(treeRefName)
    .then((commit)=> commit.getTree())
    .then((tree) => {
        obj.repositoryTree = tree;
        obj.repositoryTreeEntries = tree.entries();
        fullfill(obj);
    })
    .catch(reject);

And further listing out OID using oid method. Further trying to get commit message using:

Git.Commit
    .lookup(repository, oid)
    .then((commit) => {
        console.log(commit.message());
    })
    .then(() => fullfill(obj))
    .catch(reject);

As mentioned in lookup method. The problem is that it kept crashing. Further on a simple git log from terminal revealed that the oid was not the same as commit hash. Where exactly am I going wrong with this, to fetch the last commit that changed the file?

Matheus Lacerda
  • 5,983
  • 11
  • 29
  • 45
georoot
  • 3,557
  • 1
  • 30
  • 59
  • Could you attach the equivalent of what you want to do with the Git command line to clearly identify and understand what your use case and desired end goal is? – rcjsuen Mar 26 '18 at 22:37

1 Answers1

0

RevWalk's fileHistoryWalk function is supposed to help you achieve this but it's rather counterintuitive.

See nodegit/nodegit#1068 and nodegit/nodegit#1174

rcjsuen
  • 873
  • 1
  • 6
  • 12