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.
42 lines
1.2 KiB
42 lines
1.2 KiB
3 years ago
|
import { Repository, Commit, Diff, ConvenientPatch } from "nodegit"
|
||
|
;(async () => {
|
||
|
const repo = await Repository.open(".")
|
||
|
const master = await repo.getMasterCommit()
|
||
|
const history = master.history()
|
||
|
|
||
|
history.on("commit", async (commit: Commit) => {
|
||
|
const commitDiff = await commit.getDiff()
|
||
|
commitDiff.forEach(async (diff: Diff) => {
|
||
|
console.log(
|
||
|
"--- COMMIT ---\n",
|
||
|
commit.sha(),
|
||
|
commit.author().email(),
|
||
|
commit.date(),
|
||
|
commit.message(),
|
||
|
"deltas: ",
|
||
|
diff.numDeltas(),
|
||
|
diff?.getDelta(1)?.oldFile()?.path()
|
||
|
)
|
||
|
|
||
|
const patches = await diff.patches()
|
||
|
patches.forEach(async (patch: ConvenientPatch) => {
|
||
|
//const hunks = await patch.hunks()
|
||
|
/*hunks.forEach(async (hunk: ConvenientHunk) => {
|
||
|
console.log("diff: ", patch.oldFile().path(), patch.newFile().path())
|
||
|
console.log(hunk.header().trim())
|
||
|
|
||
|
const lines = await hunk.lines()
|
||
|
lines.forEach(async (line: DiffLine) => {
|
||
|
console.log(
|
||
|
String.fromCharCode(line.origin()) + line.content().trim()
|
||
|
)
|
||
|
|
||
|
})
|
||
|
})*/
|
||
|
})
|
||
|
})
|
||
|
})
|
||
|
|
||
|
history.start()
|
||
|
})()
|