-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (44 loc) · 1.12 KB
/
index.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
const CoreObject = require('core-object');
const simpleGit = require('simple-git');
const { CI_COMMIT_BRANCH, CI_COMMIT_TAG } = process.env;
module.exports = CoreObject.extend({
init(path) {
this._super();
this.path = path;
},
generate() {
return new Promise(resolve => {
simpleGit(this.path).log(
{
format: {
hash: '%H',
date: '%ai',
commit_message: '%s',
author_name: '%aN',
author_email: '%ae'
}
},
function(err, log) {
if (err) {
throw err;
}
if (!log || !log.latest) {
resolve();
} else {
const info = log.latest;
resolve({
sha: info.hash.replace("'", ''),
email: info.author_email.replace("'", ''),
name: info.author_name,
message: info.commit_message,
timestamp: new Date(info.date).toISOString(),
branch: CI_COMMIT_BRANCH,
tag: CI_COMMIT_TAG
});
}
}
);
});
}
});