Skip to content

Conversation

@DevelopmentCats
Copy link
Contributor

@DevelopmentCats DevelopmentCats commented Oct 24, 2025

Description

Makes the version extract and replace logic more specific so it wont replace any field that does is not specifically field under the detected modules.

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally

Related Issues

#510

@matifali matifali requested a review from Copilot October 25, 2025 10:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves version extraction logic in the version bump script to prevent false positives when matching version fields. The changes make the pattern matching more specific by ensuring only exact version field matches are replaced, rather than matching any field containing "version" in its name.

Key changes:

  • Enhanced regex patterns to match version fields more precisely using ^[[:space:]]*version[[:space:]]*= instead of version.*=.*"
  • Added explicit field name validation with $1 == "version" check
  • Improved whitespace handling by preserving original indentation

Comment on lines +80 to +86
/^[[:space:]]*version[[:space:]]*=/ {
if (in_target_module && $1 == "version") {
match($0, /^[[:space:]]*/)
indent = substr($0, 1, RLENGTH)
print indent "version = \"" new_version "\""
in_target_module = 0
next
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

The condition $1 == \"version\" will fail when there's leading whitespace because $1 will be the first whitespace-delimited field. Since the pattern already allows leading whitespace with ^[[:space:]]*, lines with indentation will have $1 as an empty string or the indented content won't split correctly. Consider using a pattern match on the line content instead, or strip leading whitespace before the field check.

Copilot uses AI. Check for mistakes.
if [ -f "$readme_path" ] && grep -q '^[[:space:]]*version[[:space:]]*=' "$readme_path"; then
local readme_version
readme_version=$(grep 'version\s*=\s*"' "$readme_path" | head -1 | sed 's/.*version\s*=\s*"\([^"]*\)".*/\1/')
readme_version=$(awk '/^[[:space:]]*version[[:space:]]*=/ && $1 == "version" { match($0, /"[^"]*"/); print substr($0, RSTART+1, RLENGTH-2); exit }' "$readme_path")
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

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

Same issue as Comment 1: The condition $1 == \"version\" will not work correctly when there's leading whitespace. The first field $1 will be determined by AWK's default field splitting on whitespace, so indented lines will cause the check to fail. Use a regex match or strip whitespace before comparing fields.

Suggested change
readme_version=$(awk '/^[[:space:]]*version[[:space:]]*=/ && $1 == "version" { match($0, /"[^"]*"/); print substr($0, RSTART+1, RLENGTH-2); exit }' "$readme_path")
readme_version=$(awk '/^[[:space:]]*version[[:space:]]*=/ { match($0, /"[^"]*"/); print substr($0, RSTART+1, RLENGTH-2); exit }' "$readme_path")

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant