-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit.js
More file actions
37 lines (29 loc) · 755 Bytes
/
git.js
File metadata and controls
37 lines (29 loc) · 755 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
30
31
32
33
34
35
36
37
const exec = require('@actions/exec');
async function commitDatetime(commitSha) {
return commitLog(commitSha, '%ci');
}
async function commitMessage(commitSha) {
return commitLog(commitSha, '%s (%h)%n%b');
}
async function commitLog(commitSha, format) {
let log = '';
let options = {
failOnStdErr: true,
silent: process.env['DEBUG'] !== 'true',
listeners: {
stdout: (data) => {
log += data.toString();
},
},
};
const path = process.env.REPOSITORY_PATH;
if (typeof path == 'string' && path !== '') {
options.cwd = path
}
await exec.exec('git', ['show', `--format=${format}`, '--no-patch', commitSha], options);
return log.trim();
}
module.exports = {
commitDatetime,
commitMessage,
}