Skip to content

Commit a06b19c

Browse files
committed
fixup
1 parent b76f268 commit a06b19c

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

utils/kernel-upgrade.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,23 +245,27 @@ update_changelog() {
245245
return 0
246246
fi
247247

248-
# Check if the latest release is UNRELEASED
249-
if ! grep -q "^\[.*\]\[UNRELEASED\]" doc/ChangeLog.md; then
250-
log_error "No UNRELEASED section found in ChangeLog.md"
248+
# Check if the latest release is UNRELEASED (first release header in file)
249+
FIRST_RELEASE=$(grep -m1 "^\[v" doc/ChangeLog.md)
250+
if ! echo "$FIRST_RELEASE" | grep -q "\[UNRELEASED\]"; then
251+
log_error "First release section in ChangeLog.md is not UNRELEASED"
251252
log_error "Please create an UNRELEASED section first before running this script"
252253
exit 1
253254
fi
254255

255-
# Add or update the kernel upgrade entry in the UNRELEASED section
256-
if grep -q "^- Upgrade Linux kernel to" doc/ChangeLog.md | head -20; then
257-
# Update existing kernel upgrade line
258-
sed -i "0,/^- Upgrade Linux kernel to.*/{s/^- Upgrade Linux kernel to.*/- Upgrade Linux kernel to $NEW_VERSION (LTS)/}" doc/ChangeLog.md
256+
# Extract just the UNRELEASED section (from start until next version header)
257+
UNRELEASED_SECTION=$(sed -n '1,/^\[v[0-9]/p' doc/ChangeLog.md | head -n -1)
258+
259+
# Check if there's already a kernel upgrade entry in the UNRELEASED section
260+
if echo "$UNRELEASED_SECTION" | grep -q "^- Upgrade Linux kernel to"; then
261+
# Update existing kernel upgrade line (only first occurrence)
262+
sed -i "0,/^- Upgrade Linux kernel to.*/{s|^- Upgrade Linux kernel to.*|- Upgrade Linux kernel to $NEW_VERSION (LTS)|}" doc/ChangeLog.md
259263
log_info "Updated existing kernel version entry to $NEW_VERSION"
260264
else
261-
# Add new kernel upgrade entry after the first "### Changes" section
262-
sed -i "0,/^### Changes/a\\
263-
\\
264-
- Upgrade Linux kernel to $NEW_VERSION (LTS)" doc/ChangeLog.md
265+
# Add new kernel upgrade entry after "### Changes" in UNRELEASED section
266+
sed -i "0,/^\[.*\]\[UNRELEASED\]/,/^### Changes/{/^### Changes/a\\
267+
- Upgrade Linux kernel to $NEW_VERSION (LTS)
268+
}" doc/ChangeLog.md
265269
log_info "Added new kernel version entry: $NEW_VERSION"
266270
fi
267271
}

0 commit comments

Comments
 (0)