-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
49 lines (45 loc) · 1.04 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
'use strict'
const debug = require('debug')('commit-info')
const {
getSubject,
getBody,
getMessage,
getEmail,
getAuthor,
getSha,
getTimestamp,
getRemoteOrigin
} = require('./git-api')
const { getBranch, getCommitInfoFromEnvironment } = require('./utils')
const Promise = require('bluebird')
const { mergeWith, or } = require('ramda')
function commitInfo (folder) {
folder = folder || process.cwd()
debug('commit-info in folder', folder)
return Promise.props({
branch: getBranch(folder),
message: getMessage(folder),
email: getEmail(folder),
author: getAuthor(folder),
sha: getSha(folder),
timestamp: getTimestamp(folder),
remote: getRemoteOrigin(folder)
}).then(info => {
const envVariables = getCommitInfoFromEnvironment()
debug('git commit: %o', info)
debug('env commit: %o', envVariables)
return mergeWith(or, envVariables, info)
})
}
module.exports = {
commitInfo,
getBranch,
getMessage,
getEmail,
getAuthor,
getSha,
getRemoteOrigin,
getSubject,
getTimestamp,
getBody
}