WeblateOrg / weblate

Web based localization tool with tight version control integration.
https://weblate.org/
GNU General Public License v3.0
4.63k stars 1.02k forks source link

Addon - Squash Git commits - commit messages and authors are not preserved #12232

Closed ahus1 closed 3 months ago

ahus1 commented 3 months ago

Describe the issue

I want to have one commit per language, and keep the authors. The docs gave me the impression that this should be possible (emphasis added by me):

Original commit messages are kept, but authorship is lost unless Per author is selected, or the commit message is customized to include it.

I didn't find documentation on how to create a commit message that can be customized to include multiple authors, so I left it blank, hoping for the best as "Append trailers to squashed commit message" was enabled.

No luck here - I now only get a generic message "Updated by "Squash Git commits" hook in Weblate.", but only on the second time I trigger the push to the target repository.

I already tried

Steps to reproduce the behavior

  1. Add the squash plugin
  2. Select "per language", enable "append trailers" and leave the commit message blank
  3. Update the translation, commit and push the change -> PR with one commit created, with original contents: https://github.com/keycloak/keycloak/commit/d42a2c47361058c9b7267121ba7c8d9bcdcdccae
  4. Update the translation again, commit and push the change -> Second commit created, and one of the commit with the generic "Updated by "Squash Git commits" hook in Weblate." message: https://github.com/keycloak/keycloak/commit/30f0a0794a43aca9cd7cbf80ae3b9b5d9ccc117a + https://github.com/keycloak/keycloak/commit/30f0a0794a43aca9cd7cbf80ae3b9b5d9ccc117a
  5. Another push, and now both commit messages are overwritten: https://github.com/keycloak/keycloak/commit/1a3ddc96aafdcbc2e7b75c4f13595d4db38bc4a6 + https://github.com/keycloak/keycloak/commit/0616b0c179ae7c4d1aa7e96e24f195b064c34449

Expected behavior

As both commits changed the same language but different components, I would have expected to see only one commit.

As I check the "append trailers", I expected the authors to be kept.

Screenshots

No response

Exception traceback

No response

How do you run Weblate?

weblate.org service

Weblate versions

No response

Weblate deploy checks

No response

Additional context

Looking at the code of the extension, it seems to me that there is some very different handling for the per-author setup - https://github.com/WeblateOrg/weblate/blob/main/weblate/addons/git.py.

As I fallback, I am reverting to the "per author" commit squashing, which works better for me, although I would still like to see one commit per language that then lists all the authors that contributed to it.

For me the one-commit-per-language would be the input for some follow-up processing of having one-PR-per-language as described in #5563

If the way I'm trying to use it is not the way it is intended to be used, I'd be happy to see a docs change. It would be great to understand how a template for "Original commit messages are kept [if] the commit message is customized to include it" would work, together with "Append trailers to squashed commit message".

nijel commented 3 months ago

The only way to include authorship when squashing across authors in including this in the trailers, that's what you see in the Co-authored-by.

ahus1 commented 3 months ago

Using Co-authored-by would be great, and this would be my expectations. Still, this information is gradually removed on every push. Looking at the example above, the first commit has Co-authored-by: Alexander Schwartz <alexander.schwartz@gmx.net>, which is then removed on the following push to the same PR. This is unexpected.

nijel commented 3 months ago

Ah, the issues is that these are missing in https://github.com/keycloak/keycloak/commit/1a3ddc96aafdcbc2e7b75c4f13595d4db38bc4a6. It appears that Weblate was unable to correctly assign this to existing translation and committed that as leftover files here:

https://github.com/WeblateOrg/weblate/blob/10fea1e28b2dcbbbb1fac0a834bf763d5a730dfd/weblate/addons/git.py#L249-L256

I think this is caused by the add-on being executed with a linked component and not the main one because of project-wide install and that should be fixed.

nijel commented 3 months ago

Something like 8c66d1d6bba will be needed for this event (or generalize the solution for repository scoped add-ons).

github-actions[bot] commented 3 months ago

Thank you for your report; the issue you have reported has just been fixed.

ahus1 commented 3 months ago

Thank you for this fix. To try it out on the hosted service on weblate.org, I assume I'll need to wait for Weblate 5.7 to be released and then installed on weblate.org?

Waiting is ok for me, I just need to know when to try it out. In the meantime, I've subscribed to the releases of this repository to get a notification upon release.

nijel commented 3 months ago

AFAIK it should be already deployed on Hosted Weblate.