You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
var nodegit = require("nodegit")
|
|
var path = require("path")
|
|
|
|
// This code examines the diffs between a particular commit and all of its
|
|
// parents. Since this commit is not a merge, it only has one parent. This is
|
|
// similar to doing `git show`.
|
|
|
|
nodegit.Repository.open(path.resolve(__dirname, ".git"))
|
|
.then(function (repo) {
|
|
return repo.getMasterCommit()
|
|
})
|
|
.then(function (commit) {
|
|
console.log("commit " + commit.sha())
|
|
console.log(
|
|
"Author:",
|
|
commit.author().name() + " <" + commit.author().email() + ">"
|
|
)
|
|
console.log("Date:", commit.date())
|
|
console.log("\n " + commit.message())
|
|
|
|
return commit.getDiff()
|
|
})
|
|
.done(function (diffList) {
|
|
diffList.forEach(function (diff) {
|
|
diff.patches().then(function (patches) {
|
|
patches.forEach(function (patch) {
|
|
patch.hunks().then(function (hunks) {
|
|
hunks.forEach(function (hunk) {
|
|
hunk.lines().then(function (lines) {
|
|
console.log(lines)
|
|
//console.log("diff", patch.oldFile().path(),
|
|
//patch.newFile().path());
|
|
//console.log(hunk.header().trim());
|
|
//lines.forEach(function(line) {
|
|
//console.log(String.fromCharCode(line.origin()) +
|
|
//line.content().trim());
|
|
//});
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|