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 // Corrected function to get the latest changelog entry from CHANGELOG.md
const getLatestChangelog = async () => { const getLatestChangelog = async () => {
try { try {
const changelogContent = await fs.readFile( const changelogPath = path.resolve(__dirname, "../CHANGELOG.md");
path.resolve(__dirname, "./CHANGELOG.md"), const changelogContent = await fs.readFile(changelogPath, "utf8");
"utf8"
);
// Regex to capture the content of the latest release. // Trim the content to remove potential leading/trailing whitespace
// It looks for a line starting with "## [" (the start of a release heading) // and split into lines for easier processing.
// and captures everything until the next "## [" or the end of the file. const lines = changelogContent.trim().split(/\r?\n/); // Handles both \n and \r\n
// 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
);
if (latestEntryMatch && latestEntryMatch[1]) { let latestReleaseNotes = [];
// Split the matched content into lines let inLatestRelease = false;
const lines = latestEntryMatch[1].split("\n"); let foundFirstHeading = false;
// Find the index of the first non-heading line for (const line of lines) {
// The first line is usually the heading (e.g., "## [1.0.0] - 2024-01-01") // Check for a release heading (e.g., "## [0.0.3-alpha.15] (2025-07-12)")
// So we start checking from the second line (index 1). if (line.match(/^## \[.*?\] \(.*?\)$/)) {
let firstContentLineIndex = -1; if (!foundFirstHeading) {
for (let i = 1; i < lines.length; i++) { // This is the first release heading we encounter, so start capturing
if (lines[i].trim() !== "") { inLatestRelease = true;
// Check for non-empty and non-whitespace lines foundFirstHeading = true;
firstContentLineIndex = i; // 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; break;
} }
} }
if (firstContentLineIndex !== -1) { // If we are currently inside the latest release block, add the line
// Join the lines from the first content line onwards and trim any leading/trailing whitespace if (inLatestRelease) {
return lines.slice(firstContentLineIndex).join("\n").trim(); 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 { } else {
console.warn( 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) { } catch (err) {
console.error("Error reading or parsing CHANGELOG.md:", err); console.error("Error reading or parsing CHANGELOG.md:", err);