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
16.86k stars 2.2k forks source link

Renovate doesn't detect semantic commit usage for onboarding MR commit message #26720

Open rarkins opened 7 months ago

rarkins commented 7 months ago

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

Originally posted by **NSenaud** January 17, 2024 ### How are you running Renovate? Self-hosted Renovate ### If you're self-hosting Renovate, tell us what version of Renovate you run. 37.137.3 ### If you're self-hosting Renovate, select which platform you are using. GitLab self-hosted ### Was this something which used to work for you, and then stopped? I have not seen this working ### Describe the problem When using default `semanticCommits` value (`auto`), the on-boarding commit message is not respecting semantic commit syntax (on-boarding merge request name is prepend by `chore:` however). ![image](https://github.com/renovatebot/renovate/assets/2766897/25364131-13fa-4e9c-9a71-3bd9668091f2) When forcing `semanticCommits` to `enabled` the on-boarding commit message is properly formatted: ![image](https://github.com/renovatebot/renovate/assets/2766897/5aa3156c-c5e4-4dd0-8b01-30a8ec264c07) I am not familiar with JavaScript/TypeScript, but I can't find any existing logic for the `auto` setting in: https://github.com/renovatebot/renovate/blob/main/lib/workers/repository/onboarding/branch/. Documentation states: > If `commitMessagePrefix` or `semanticCommits` values are set then they will be prepended to the commit message using the same logic that is used for adding them to non-onboarding commit messages. Which doesn't explicitly say that the `auto` value is not supported for `semanticCommits` setting. Access to the GitLab instance is restricted, so I can't easily provide a reproduction repository, but the description should be straightforward. Thank you for this very awesome tool :+1: ### Relevant debug logs _No response_ ### Have you created a minimal reproduction repository? Reproduction: https://github.com/renovate-reproductions/26708
pascal-hofmann commented 5 months ago

Hi @rarkins, I noticed the same issue and debugged it. I have no idea how to fix this properly, but maybe my findings are useful for you:

The commit message is wrong, because the commit is created in createOnboardingBranch (located in lib/workers/repository/onboarding/branch/create.ts), and at this stage config.semanticCommits is auto and no auto-detection is done. Thus the CommitMessageFactory does not use semantic commits (as areSemanticCommitsEnabled only checks for enabled).

The PR title for onboarding PRs ends up correct though, because renovateRepository in lib/workers/repository/index.ts contains this code prior to PR creation:

    if (config.semanticCommits === 'auto') {
      config.semanticCommits = await detectSemanticCommits();
    }
viceice commented 5 months ago

nice found. it seems we need this check in create onboarding commit too.

lschricke-hw commented 2 months ago

Hello, we are experiencing the same issue here.