Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/scripts/addZoektSyncChangelogEntry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ awk -v entry="$entry" '
next
}

in_unreleased && !found_changed && /^## / {
print "### Changed"
print entry
print ""
found_changed = 1
inserted = 1
in_unreleased && /^## / {
if (!found_changed) {
print "### Changed"
print entry
print ""
found_changed = 1
inserted = 1
}
in_unreleased = 0
print
next
Expand Down
11 changes: 11 additions & 0 deletions .github/scripts/testZoektSync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ cat > "$changelog_fixture" <<'EOF'
- Fixed something.

## [1.0.0]

### Changed
- Changed something in a released version.

## [0.9.0]

### Changed
- Changed something in an older released version.
EOF

chmod 640 "$changelog_fixture"
Expand All @@ -155,6 +163,9 @@ assert_contains "$changelog_fixture" \
assert_contains "$changelog_fixture" \
"- Updated the bundled Zoekt version. [#42](https://github.com/sourcebot-dev/sourcebot/pull/42)" \
"the changelog helper should add the generated PR link"
entry_count=$(grep -Fc "sourcebot/pull/42" "$changelog_fixture")
assert_equals "$entry_count" 1 \
"the changelog helper should add the PR entry only to Unreleased"
Comment on lines +166 to +168

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the entry location, not only the total count.

This assertion scans the full fixture. It passes if the helper inserts the entry once in a released ### Changed section. Count the entry inside the block from ## [Unreleased] to the next ## heading, and keep the total-count assertion to verify both scope and uniqueness.

Proposed assertion
 entry_count=$(grep -Fc "sourcebot/pull/42" "$changelog_fixture")
 assert_equals "$entry_count" 1 \
   "the changelog helper should add the PR entry only to Unreleased"
+unreleased_entry_count=$(awk '
+  $0 == "## [Unreleased]" { in_unreleased = 1; next }
+  in_unreleased && /^## / { exit }
+  in_unreleased && /sourcebot\/pull\/42/ { count++ }
+  END { print count + 0 }
+' "$changelog_fixture")
+assert_equals "$unreleased_entry_count" 1 \
+  "the changelog helper should place the PR entry inside Unreleased"

As stated in the PR objectives, the generated entry must be scoped to Unreleased.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
entry_count=$(grep -Fc "sourcebot/pull/42" "$changelog_fixture")
assert_equals "$entry_count" 1 \
"the changelog helper should add the PR entry only to Unreleased"
entry_count=$(grep -Fc "sourcebot/pull/42" "$changelog_fixture")
assert_equals "$entry_count" 1 \
"the changelog helper should add the PR entry only to Unreleased"
unreleased_entry_count=$(awk '
$0 == "## [Unreleased]" { in_unreleased = 1; next }
in_unreleased && /^## / { exit }
in_unreleased && /sourcebot\/pull\/42/ { count++ }
END { print count + 0 }
' "$changelog_fixture")
assert_equals "$unreleased_entry_count" 1 \
"the changelog helper should place the PR entry inside Unreleased"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/testZoektSync.sh around lines 166 - 168, Update the
changelog assertions around the existing entry_count check to count
“sourcebot/pull/42” specifically within the fixture block from “## [Unreleased]”
through the next “## ” heading, while retaining the full-fixture count assertion
to verify uniqueness. Ensure the assertions confirm the entry appears exactly
once and only under Unreleased.

CHANGELOG_PATH="$changelog_fixture" "$changelog_script" 42
entry_count=$(grep -Fc "sourcebot/pull/42" "$changelog_fixture")
assert_equals "$entry_count" 1 \
Expand Down
Loading