fix(h): sssdasjhksdf

This commit is contained in:
2025-07-12 17:27:43 -05:00
parent 7cbc8c8b84
commit e6041b03ee

View File

@@ -69,46 +69,50 @@ if (!GITEA_URL || !GITEA_USERNAME || !GITEA_REPO || !GITEA_TOKEN) {
// Corrected function to get the latest changelog entry from CHANGELOG.md
const getLatestChangelog = async () => {
try {
const changelogContent = await fs.readFile(
path.resolve(__dirname, "./CHANGELOG.md"),
"utf8"
);
const changelogPath = path.resolve(__dirname, "../CHANGELOG.md");
const changelogContent = await fs.readFile(changelogPath, "utf8");
// Regex to capture the content of the latest release.
// It looks for a line starting with "## [" (the start of a release heading)
// and captures everything until the next "## [" or the end of the file.
// The `m` flag makes `^` and `$` match start/end of lines, not just string.
// The `s` flag allows `.` to match newlines.
const latestEntryMatch = changelogContent.match(
/^(## \[.*?\] - .*?\n[\s\S]*?)(?=^## \[|\Z)/m
);
// Trim the content to remove potential leading/trailing whitespace
// and split into lines for easier processing.
const lines = changelogContent.trim().split(/\r?\n/); // Handles both \n and \r\n
if (latestEntryMatch && latestEntryMatch[1]) {
// Split the matched content into lines
const lines = latestEntryMatch[1].split("\n");
let latestReleaseNotes = [];
let inLatestRelease = false;
let foundFirstHeading = false;
// Find the index of the first non-heading line
// The first line is usually the heading (e.g., "## [1.0.0] - 2024-01-01")
// So we start checking from the second line (index 1).
let firstContentLineIndex = -1;
for (let i = 1; i < lines.length; i++) {
if (lines[i].trim() !== "") {
// Check for non-empty and non-whitespace lines
firstContentLineIndex = i;
for (const line of lines) {
// Check for a release heading (e.g., "## [0.0.3-alpha.15] (2025-07-12)")
if (line.match(/^## \[.*?\] \(.*?\)$/)) {
if (!foundFirstHeading) {
// This is the first release heading we encounter, so start capturing
inLatestRelease = true;
foundFirstHeading = true;
// Skip the heading line itself, or capture it if you want it in the notes
// For typical release notes, you usually want the content *under* the heading.
continue; // Skip the heading line itself from the notes
} else {
// We've found a second release heading, meaning the latest release notes have ended
break;
}
}
if (firstContentLineIndex !== -1) {
// Join the lines from the first content line onwards and trim any leading/trailing whitespace
return lines.slice(firstContentLineIndex).join("\n").trim();
// If we are currently inside the latest release block, add the line
if (inLatestRelease) {
latestReleaseNotes.push(line);
}
return ""; // No content found after heading
}
// Clean up the collected notes
const cleanedNotes = latestReleaseNotes.join("\n").trim();
if (cleanedNotes) {
console.log("Successfully extracted latest changelog notes.");
return cleanedNotes;
} else {
console.warn(
"Could not find the latest changelog entry in CHANGELOG.md. Ensure it's formatted correctly."
"Could not find any content for the latest changelog entry in CHANGELOG.md."
);
return "No changelog notes available."; // Default message if not found
return "No changelog notes available.";
}
} catch (err) {
console.error("Error reading or parsing CHANGELOG.md:", err);