mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
38 lines
876 B
JavaScript
38 lines
876 B
JavaScript
const { yParser, execa, chalk } = require('@nodecorejs/libs');
|
|
|
|
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;
|
|
};
|