Closed nijel closed 5 years ago
It could be probably done with git filter-branch
see https://stackoverflow.com/a/38872224/225718
Yeah, git filter-branch
can do that. It would need to filter based on file and author in the first pass. Then there would need to be a rebase with fixup commits to merge all the consecutive commits by the same author. For example, a list of commits modifying the same, labeled by author:
Would become:
I suppose it would be even nicer if it was down to just two commits, one for foo and one for bar, but that seems trickier. I suppose it could try the rebase to see if it works, and otherwise only squash consecutive matching commits.
Hmm, but the same author commits probably won't be next to each other in most cases. Probably it would be better to use GIT_SEQUENCE_EDITOR
(or setting sequence.editor
) and git rebase -i
to achieve desired behavior.
Any thoughts on adding a(nother) commit style that sacrifices the VCS author information in favor of a single commit that includes author information in the commit message? Perhaps even with an option to have a single commit per language (one language/file, mulitple users) vs. a single commit for everything (multiple languages/files, multiple users)?
That's option as well. The difference is that contrary to rebase approach it won't deal with already committed and not yet merged changes. Currently commit_pending is responsible for groupping changes by author into commit:
I just came across another interresting case in our installation. We have one project with ten components (one of them is a real Git repo, the other nine are links with enabled translation propagation) and one of our translators made changes in two languages. The result was 17 commits across pretty much all of the components with a mix of languages; sometimes alternating between the two and sometimes multiple components for the same language, then for the other.
Consolidating those into fewer commits (in this case: all from the same author; so perhaps one commit as "per author" style or two commits "per language" style) would be something nice, especially in the propagation case.
@BhaaLseN This really should be much better in recent versions, what version do you use?
I'm still on 3.0.1, but the next maintenance window is coming up so I'll be looking forward to it!
Some of the changes are not even in 3.1, see https://github.com/WeblateOrg/weblate/issues/2157.
That does look a bit like half the commits I saw there; but won't change that fact that we're still going to upgrade to the most recent one soon, nor the fact that I'm looking forward to more/other/different styles in the future.
Full squash could be done by following (based on https://stackoverflow.com/a/29310055/225718):
message=`git log --format=%B origin/master..HEAD`
git reset --soft origin/master
git commit -m "$message"
Seems like that nice little hack would then make it easy to do per-language commits, something like:
declare -A messages
for locale in $locales; do
messages[$locale]=`git log --format="%an <%ae>" origin/master..HEAD locale/${locale}/LC_MESSAGES/fdroidserver.po | sort -u`
done
git reset --soft origin/master
for locale in $locales; do
git commit -m "${messages[$locale]}" locale/${locale}/LC_MESSAGES/fdroidserver.po
done
WIP implementation: https://github.com/WeblateOrg/weblate/pull/2462
I've just merged #2462 adding support to squash all, per file or per language. Squashing per author still missing.
Haven't looked at it yet, but does (or will) it support per language on linked repositories? I got one project with 12 components that all target different sets of files inside the same repository (and also propagate changes between them); where I'd like to see a total of 3 commits if de/en/fr were changed (even if 36 files were affected by this)
Yes, per language works across all linked repos (that's why there is per language and per file).
how you implemented per language sounds great!
How would we try this on an fdroid component? I couldn't see anything in the settings.
@matrixcoffee FYI
It's an addon, configure and install it on https://hosted.weblate.org/addons/f-droid/f-droid/
I'm still stumped on this. I've enabled the addon in two projects and set them to "per-language" and "per-file":
But they don't seem to do the squashing at all. Do I have to do something to trigger it?
The squash currently happens on push only and you don't have enabled that. Probably something what needs to be addressed...
...what makes little sense, it really should be done after every commit. I've changed that in https://github.com/WeblateOrg/weblate/commit/27a88856e18eb6780c9f106e2e79bd11a363665d, will be deployed once the tests pass.
So I just tried it with this: https://hosted.weblate.org/projects/f-droid/repomaker/#repository.
Maybe it is related to this component, which shares the same git repo, does not have "Squash Git commits" as an available Addon.
The problem now is that "commit" does only commit if there are some pending changes ;-).
As there is no translation in language I know, I've tested it on the fdroidserver and it seems to work fine - I've made two commits there and the updates were squashed per file as configured.
FYI, the new Fastlane support #1525 does not seem to get squashed by the addon, as seen in https://hosted.weblate.org/projects/f-droid/f-droid/
It is set to per-language squashing
Hmm, two languages just got squashed. It seems that it will only squash if there is a new commit on the primary component (e.g. f-droid/f-droid), while it does not squash when there are new commits on the secondary component (e.g. f-droid/f-droid-metadata).
Your guess is correct, I've just addressed this case in 0155dfc73690b7b7a678fa3b6bf1c89006f5f4bb. No schedule for deploying this fix yet...
Something strange is going on with https://hosted.weblate.org/projects/f-droid/f-droid/ which seems related to this new feature but might also be related to the new Fastlane support.
Translated using Weblate: Basque (eu) by Osoitz <oelkoro@gmail.com>
Currently translated at 100.0% (428 of 428 strings)
Translated using Weblate (Turkish)
Currently translated at 63.2% (12 of 19 strings)
Translation: F-Droid/F-Droid metadata
Translate-URL: https://hosted.weblate.org/projects/f-droid/f-droid-metadata/tr/
Translated using Weblate (Turkish)
Currently translated at 63.2% (12 of 19 strings)
Translation: F-Droid/F-Droid metadata
Translate-URL: https://hosted.weblate.org/projects/f-droid/f-droid-metadata/tr/
Translated using Weblate (English (United States))
Currently translated at 100.0% (18 of 18 strings)
Translation: F-Droid/F-Droid metadata
Translate-URL: https://hosted.weblate.org/projects/f-droid/f-droid-metadata/en_US/
Translated using Weblate: Esperanto (eo) by Hans-Christoph Steiner <hans@guardianproject.info>
Currently translated at 99.8% (427 of 428 strings)
Translated using Weblate: Esperanto (eo) by Verdulo <tomek@disroot.org>
Currently translated at 99.8% (427 of 428 strings)
-------------------- app/src/main/res/values-eo/strings.xml --------------------
I've already fixed the repo manually meanwhile. Fixed in Weblate by 1394442e2e380d6b49c28632cf2b58381e523f50
Thank you for your report, the issue you have reported has just been fixed.
Currently there are merge and rebase merge styles in Weblate. It might be useful to have additional one which would rebase commit and squash them. It would squash commits from same author and same file, using commit message from last one. This would be useful for projects who want to minimize amount of translation commits.
It might be either supported natively in Weblate VCS layer or as an addon. Having it as addon seems more reasonable to me as this is probably going to be supported only for Git.