Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
ahus1 opened this issue Aug 8, 2024 · 7 comments · Fixed by #12238
Closed
2 tasks done

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

ahus1 opened this issue Aug 8, 2024 · 7 comments · Fixed by #12238
Assignees
Labels
bug Something is broken.
Milestone

Comments

@ahus1
Copy link

ahus1 commented Aug 8, 2024

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

  • I've read and searched the documentation.
  • I've searched for similar filed issues in this repository.

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:
    keycloak/keycloak@d42a2c4
  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:
    keycloak/keycloak@30f0a07 + keycloak/keycloak@30f0a07
  5. Another push, and now both commit messages are overwritten: keycloak/keycloak@1a3ddc9 + keycloak/keycloak@0616b0c

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
Copy link
Member

nijel commented Aug 8, 2024

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
Copy link
Author

ahus1 commented Aug 8, 2024

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
Copy link
Member

nijel commented Aug 9, 2024

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

# Commit any left files, those were most likely generated
# by addon and do not exactly match patterns above
component.commit_files(
template=component.addon_message,
extra_context={"addon_name": self.verbose},
signals=False,
skip_push=True,
)

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 nijel added the bug Something is broken. label Aug 9, 2024
@nijel nijel added this to the 5.7 milestone Aug 9, 2024
@nijel
Copy link
Member

nijel commented Aug 9, 2024

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

nijel added a commit to nijel/weblate that referenced this issue Aug 9, 2024
We need a more generic approach to avoid handling this per signal and
add-on. See WeblateOrg#12232
nijel added a commit to nijel/weblate that referenced this issue Aug 9, 2024
These should not be executed on linked components, but only on the main
one. This is generic solution to the problem replacing previous specific
solution to single event and add-on.

Fixes WeblateOrg#12232
Fixes WeblateOrg#10892
nijel added a commit to nijel/weblate that referenced this issue Aug 9, 2024
We need a more generic approach to avoid handling this per signal and
add-on. See WeblateOrg#12232
nijel added a commit to nijel/weblate that referenced this issue Aug 9, 2024
These should not be executed on linked components, but only on the main
one. This is generic solution to the problem replacing previous specific
solution to single event and add-on.

Fixes WeblateOrg#12232
Fixes WeblateOrg#10892
@nijel nijel self-assigned this Aug 9, 2024
nijel added a commit that referenced this issue Aug 9, 2024
We need a more generic approach to avoid handling this per signal and
add-on. See #12232
nijel added a commit that referenced this issue Aug 9, 2024
These should not be executed on linked components, but only on the main
one. This is generic solution to the problem replacing previous specific
solution to single event and add-on.

Fixes #12232
Fixes #10892
Copy link

github-actions bot commented Aug 9, 2024

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

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

@ahus1
Copy link
Author

ahus1 commented Aug 12, 2024

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
Copy link
Member

nijel commented Aug 12, 2024

AFAIK it should be already deployed on Hosted Weblate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants