@wroud/git
Version:
A lightweight toolset for working with local git, including utilities for retrieving git commits and tags, ideal for CI/CD pipelines and automated release workflows.
24 lines • 808 B
JavaScript
import { execa } from "execa";
import semverRegex from "semver-regex";
import { validateGitEnvironment } from "./validateGitEnvironment.js";
import { defaultTagPrefix } from "./defaultTagPrefix.js";
export async function* getGitLastSemverTags({ to, prefix = defaultTagPrefix, } = {}) {
await validateGitEnvironment();
try {
const args = ["tag", "--list", `${prefix}*`];
if (to) {
args.push("--merged", to);
}
args.push("--sort=-v:refname");
for await (const tag of execa("git", args)) {
if (tag.startsWith(prefix) &&
semverRegex().test(tag.slice(prefix.length))) {
yield tag;
}
}
}
catch (e) {
console.error(e);
}
}
//# sourceMappingURL=getGitLastSemverTags.js.map