-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (26 loc) · 945 Bytes
/
Copy pathindex.js
File metadata and controls
29 lines (26 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var Git = require("nodegit");
const REPO = process.env.REPO
const FILESYSTEM_LOCATION = process.env.FILESYSTEM_LOCATION
const HUB_LOCATION = "https://github.com"
const makeMessage = (commit) => {
// 72 characters no new lines
const message = commit.message().substr(0,72).replace(/\n|\r/g, "")
const webUrl = `${HUB_LOCATION}/${REPO}/commits/${commit.sha()}`
const author = commit.author().name()
const date = commit.date().toLocaleDateString()
return `${author}: ${date} :[${message}](${webUrl})`
}
const go = async function(){
const repo = await Git.Repository.open(FILESYSTEM_LOCATION)
// TODO: figure out non master branch flow
const masterCommit = await repo.getMasterCommit()
const history = masterCommit.history()
let count = 0
history.on("commit", function(commit) {
// it works and get-last-5 is the name
if (++count >= 6) return
console.log(makeMessage(commit));
});
history.start();
}
go()