feat(updaters): add Gradle version catalog TOML updater - #597
Conversation
Implements TC-5412 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Assisted-by: Claude Code
Reviewer's GuideAdds a new TOML-based Gradle version catalog updater and comprehensive tests/fixtures to support updating dependency versions via centralized refs, inline declarations, and shorthand strings while preserving formatting and comments. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/updaters/toml_updater.js" line_range="238-247" />
<code_context>
+ * @param {string} newVersion - replacement version string
+ * @returns {string} updated content
+ */
+function replaceInlineVersion(content, alias, oldVersion, newVersion) {
+ const escapedAlias = escapeRegExp(alias)
+ const escapedOld = escapeRegExp(oldVersion)
+ const pattern = new RegExp(
+ `^(\\s*${escapedAlias}\\s*=\\s*\\{[^}]*version\\s*=\\s*")${escapedOld}("[^}]*\\}\\s*)$`,
+ 'm'
+ )
+ const result = content.replace(pattern, `$1${newVersion}$2`)
+ if (result !== content) {
+ return result
+ }
+ const stringPattern = new RegExp(
+ `^(\\s*${escapedAlias}\\s*=\\s*"[^:]+:[^:]+:)${escapedOld}("\\s*)$`,
+ 'm'
+ )
+ return content.replace(stringPattern, `$1${newVersion}$2`)
+}
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Handle failure to match inline versions to avoid false positives in `applied`
`replaceInlineVersion` can return the original `content` when neither regex matches (e.g. formatting differences or the version being in a different position), but the caller still records this as applied. Consider detecting when no replacement occurs and propagating that information so the caller can mark the change as skipped instead. For example, return `{ content, replaced: boolean }` or compare the result with the input and act accordingly.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| function replaceInlineVersion(content, alias, oldVersion, newVersion) { | ||
| const escapedAlias = escapeRegExp(alias) | ||
| const escapedOld = escapeRegExp(oldVersion) | ||
| const pattern = new RegExp( | ||
| `^(\\s*${escapedAlias}\\s*=\\s*\\{[^}]*version\\s*=\\s*")${escapedOld}("[^}]*\\}\\s*)$`, | ||
| 'm' | ||
| ) | ||
| const result = content.replace(pattern, `$1${newVersion}$2`) | ||
| if (result !== content) { | ||
| return result |
There was a problem hiding this comment.
issue (bug_risk): Handle failure to match inline versions to avoid false positives in applied
replaceInlineVersion can return the original content when neither regex matches (e.g. formatting differences or the version being in a different position), but the caller still records this as applied. Consider detecting when no replacement occurs and propagating that information so the caller can mark the change as skipped instead. For example, return { content, replaced: boolean } or compare the result with the input and act accordingly.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #597 +/- ##
==========================================
+ Coverage 91.01% 91.21% +0.20%
==========================================
Files 38 39 +1
Lines 8001 8264 +263
Branches 1395 1438 +43
==========================================
+ Hits 7282 7538 +256
- Misses 719 726 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Summary
src/updaters/toml_updater.jsmodule withupdateTomlVersions()APIversion.ref, inlineversion = "x.y.z", and string shorthand patternsgroup/namenotation alongsidemodulenotationImplements TC-5412
Test plan
version.refnpm run lintpassesnpm testpassesSummary by Sourcery
Add a TOML updater for Gradle version catalogs and comprehensive tests and fixtures to validate version update behavior.
New Features:
Tests: