renovatebot / renovate

Home of the Renovate CLI: Cross-platform Dependency Automation by Mend.io
https://mend.io/renovate
GNU Affero General Public License v3.0
17.1k stars 2.22k forks source link

Support autoreplace for sbt manager #25643

Open rarkins opened 10 months ago

rarkins commented 10 months ago

Discussed in https://github.com/renovatebot/renovate/discussions/25637

Originally posted by **gaeljw** November 7, 2023 ### How are you running Renovate? Mend Renovate hosted app on github.com ### If you're self-hosting Renovate, tell us what version of Renovate you run. _No response_ ### If you're self-hosting Renovate, select which platform you are using. None ### Was this something which used to work for you, and then stopped? I never saw this working ### Wanted end result. Given the following repository: https://github.com/gaeljw/renovate-replacement-play, I'd like to get a PR opened using the "replacement" feature because one of my dependencies got its name changed. - `"com.typesafe.play" % "sbt-plugin"` is renamed to `"org.playframework" % "sbt-plugin"` ### What you tried so far. I've added the following replacement rules to my `renovate.json` config: ```json "packageRules": [ { "matchPackageNames": [ "com.typesafe.play:sbt-plugin" ], "replacementName": "org.playframework:sbt-plugin", "replacementVersion": "3.0.0" } ] ``` But so far, I don't get any replacement PR opened. I only get new versions on the "old" naming, I'd like to get additional PRs with the new name and version 3.0.0. ### Relevant debug logs
Logs ``` "sbt": [ { "deps": [ { "datasource": "sbt-plugin", "depName": "com.typesafe.play:sbt-plugin", "packageName": "com.typesafe.play:sbt-plugin", "currentValue": "2.9.0", "depType": "plugin", "registryUrls": [ "https://repo.maven.apache.org/maven2", "https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases" ], "updates": [ { "updateType": "replacement", "newName": "org.playframework:sbt-plugin", "newValue": "3.0.0", "branchName": "renovate/com.typesafe.play-sbt-plugin-replacement" } ], "versioning": "ivy", "warnings": [], "sourceUrl": "https://github.com/playframework/playframework", "registryUrl": "https://repo.maven.apache.org/maven2", "dependencyUrl": "https://repo.maven.apache.org/maven2/com/typesafe/play/sbt-plugin", "currentVersion": "2.9.0", "fixedVersion": "2.9.0" } ], "packageFile": "project/plugins.sbt" } ] } ... INFO: Cannot find replaceString in current file content. Was it already updated? (branch="renovate/com.typesafe.play-sbt-plugin-replacement") { "packageFile": "project/plugins.sbt" "depName": "com.typesafe.play:sbt-plugin" "existingContent": "\naddSbtPlugin(\"com.typesafe.play\" % \"sbt-plugin\" % \"2.9.0\")\n" "replaceString": "2.9.0" } DEBUG: No content changed (branch="renovate/com.typesafe.play-sbt-plugin-replacement") { "packageFile": "project/plugins.sbt" "depName": "com.typesafe.play:sbt-plugin" } ```
I guess the error `Cannot find replaceString in current file content` is relevant but I'm not sure how to fix it.
gaeljw commented 10 months ago

Happy to give a try at implementing this if someone can guide me in the right direction.

rarkins commented 10 months ago

In the meantime, the current docs should be updated to include SBT in the unsupported list: https://docs.renovatebot.com/configuration-options/#replacementname

rarkins commented 10 months ago

I searched the code for replacementName and unfortunately I'm not finding any custom replacements. For example maven is not supported.

We may need to add some maven-awareness to the autoreplace function, e.g. instead of searching for the packageName string in full, we split it into group and package parts and then search for something like groupPart.*?packagePart and then replace them separately if found

gaeljw commented 10 months ago

Indeed, if this is not implemented for any other manager yet, this sounds like a bit of work.

gaeljw commented 10 months ago

Related to https://github.com/renovatebot/renovate/issues/14149

MPV commented 3 months ago

Should SBT also be listed here...?