Get commits list of a repository


#1

Ok, so I’m using the Atom API to get a list of repository and then a list of it’s heads via this:

var repos = atom.project.getRepositories();
var heads = [];

repos.forEach(function (repo) {
    heads.push(repo.getReferences().heads);
});

But so far I haven’t found a way to get a list of the commits for each of those heads. getReferences only returns an array of heads, remotes and tags.

Also, the only reference I see in the Atom API about git is in https://atom.io/docs/api/v1.0.2/GitRepository and I can’t seem to find any references of “commit” in there. Is this not implemented yet or am I missing something?


#2

Not implementing all parts of Git through the Atom API was a specific choice that the Atom team made:

But packages are welcome to add their own Git support.


#3

Check out the Git-log package. It’s doing a pretty good job at visualizing the git history of a repository so its code should give you some clues.


#4

Thanks you both for the replies, it’s kinda sad we don’t have build-in support but it’s understandable.

I ended up writing something like this:


#5

That’s cool.
I haven’t tried it out, but if it works that’s certainly one way to construct a nice list of commits to work on.

I suppose one could also make use of some npm package for git.