forked from umijs/umi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.js
More file actions
37 lines (32 loc) · 872 Bytes
/
git.js
File metadata and controls
37 lines (32 loc) · 872 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 { yParser, execa, chalk } = require('@umijs/utils');
exports.latestTag = async () => {
const { stdout } = await execa('git', ['describe', '--abbrev=0', '--tags']);
return stdout;
};
const firstCommit = async () => {
const { stdout } = await execa('git', [
'rev-list',
'--max-parents=0',
'HEAD',
]);
return stdout;
};
exports.latestTagOrFirstCommit = async () => {
let latest;
try {
// In case a previous tag exists, we use it to compare the current repo status to.
latest = await exports.latestTag();
} catch (_) {
// Otherwise, we fallback to using the first commit for comparison.
latest = await firstCommit();
}
return latest;
};
exports.commitLogFromRevision = async (revision) => {
const { stdout } = await execa('git', [
'log',
'--format=%s %h',
`${revision}..HEAD`,
]);
return stdout;
};