git-release-manager
Version:
A tool to generate release notes from git commit history
28 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTagsAsync = getTagsAsync;
const cmd_1 = require("../../../utils/cmd");
async function getTagsAsync() {
const { stdout: allTagsOutput } = await (0, cmd_1.execWithErrorHandling)('git tag');
const allTags = cleanList(allTagsOutput);
const all = await Promise.all(allTags.map(getTagDetail));
const latest = all.length > 0 ? all[all.length - 1] : null;
return {
latest,
all,
};
}
const cleanList = (output) => (output === null || output === void 0 ? void 0 : output.split('\n').map(line => line.trim()).filter(Boolean)) || [];
async function getTagDetail(tag) {
try {
const command = `git show ${tag} --no-patch --pretty=format:"%h %ai"`;
const { stdout } = await (0, cmd_1.execWithErrorHandling)(command);
const [reference, date] = stdout.split(' ', 2);
return { name: tag, reference, date };
}
catch (error) {
console.error(`Error getting details for tag ${tag}:`, error);
throw error;
}
}
//# sourceMappingURL=tagHandler.js.map