UNPKG

git-release-manager

Version:

A tool to generate release notes from git commit history

48 lines 1.65 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCommitCount = getCommitCount; exports.isGitCommit = isGitCommit; exports.resolveCommitId = resolveCommitId; const simple_git_1 = __importDefault(require("simple-git")); const refUtils_1 = require("./refUtils"); const cmd_1 = require("../../../utils/cmd"); const git = (0, simple_git_1.default)(); async function getCommitCount(range) { let commitCount = 0; try { const { stdout } = await (0, cmd_1.execWithErrorHandling)(`git rev-list --count ${range}`); commitCount = parseInt(stdout.trim(), 10); return commitCount; } catch (error) { console.error('Error counting commits in range:', error); throw error; } } /** * Checks if the given value is a valid Git commit. * * @param value - The value to check if it is a valid Git commit. * @returns A promise that resolves to a boolean indicating whether the value is a valid Git commit. */ async function isGitCommit(value) { return (0, refUtils_1.revParse)(value); } /** * Resolves the commit ID for a given reference. * * @param value - The reference to resolve (e.g., branch name, tag, or commit hash). * @returns A promise that resolves to the commit ID as a string, or null if the reference cannot be resolved. */ async function resolveCommitId(value) { try { return await git.revparse([value]); } catch (_a) { return null; } } //# sourceMappingURL=commitUtils.js.map