node-libgit2-log-utils
v0.3.0
Published
Simple utility functions for fetching git history using libgit2 built for Nodejs
Downloads
3
Maintainers
Readme
node-libgit2-log-utils
Simple utility functions for fetching git history using nodegit (libgit2) built for Nodejs
This package wraps the libgit2-log-utils package to work in the node enviroment without needing to separately require 'nodegit'.
This package should not be used from an Atom package. See atom-libgit2-log-utils for Atom support.
Installation (from your Atom package's source root):
npm install node-libgit2-log-utils
Usage
var gitLogUtils = require('node-libgit2-log-utils');
gitLogUtils.getCommitHistory("myPath/maybeMyFile")
.then(function(history) {
return console.log(JSON.stringify(history, null, 2));
})
.catch(function(error) {
return console.error(error);
});
...will produce...
[
{
"id": "233b26b3a1e212e50693e2e41f2252afa7ebf16d",
"author": "Bee",
"authorDate": 1461978358000,
"message": "output linesAdded and linesDeleted for each file",
"body": "",
"hash": "233b26b3a1e212e50693e2e41f2252afa7ebf16d",
"linesAdded": 35,
"linesDeleted": 15,
"files": [
{
"path": "package.json",
"linesAdded": 3,
"linesDeleted": 1
},
{
"path": "src/libgit2-log-utils.coffee",
"linesAdded": 31,
"linesDeleted": 13
},
{
"path": "test/scripts/getLogJson.coffee",
"linesAdded": 1,
"linesDeleted": 1
}
]
},
{
"id": "more like the above ..."
}
]
The getCommitHistory() method will accept a file or directory and can also handle absolute (full path) path specifications.