git-release-manager
Version:
A tool to generate release notes from git commit history
41 lines • 1.3 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.revParse = revParse;
exports.isGitRef = isGitRef;
exports.parseRange = parseRange;
const simple_git_1 = __importDefault(require("simple-git"));
const git = (0, simple_git_1.default)();
/**
* Asynchronously checks if a given Git reference exists.
*
* @param value - The Git reference to check (e.g., branch name, commit hash).
* @returns A promise that resolves to `true` if the reference exists, otherwise `false`.
*/
async function revParse(value) {
try {
const result = await git.revparse([value]);
return !!result;
}
catch (_a) {
return false;
}
}
/**
* Checks if the given value is a valid Git reference.
*
* @param value - The string to check as a Git reference.
* @returns A promise that resolves to `true` if the value is a valid Git reference, otherwise `false`.
*/
async function isGitRef(value) {
return revParse(value);
}
function parseRange(range) {
if (!range)
return { from: null, to: null };
const [from, to] = range.split('..');
return { from, to };
}
//# sourceMappingURL=refUtils.js.map