Bug #15401
Create hooks to be implemented on the Weblate instance
10%
Description
git diff -- . ':(exclude)*.po'
will tell us if there is anything else that has been modified. If yes, we need to abort the commit.
Subtasks
Related issues
Related to Tails - |
Resolved |
History
#1 Updated by Anonymous 2018-03-13 12:53:32
- Deliverable for set to Sponsor_L
#!/bin/sh
# Disallow committing changes that did not happen on po files.
# Pre commit hook for weblate instance.
# and as pre-receive hook on main git, although here we need to check if it's weblate that pushes.
if ! git diff --quiet --name-only --exit-code -- . ':(exclude)*.po'
then
echo >&2 "Error: Cannot commit! The repository contains files that are not *. po files."
git diff --name-only --exit-code -- . ':(exclude)*.po' >&2
fi
This is the pre commit hook we should install on the weblate instance.
#2 Updated by Anonymous 2018-03-13 12:53:43
- Status changed from Confirmed to In Progress
- % Done changed from 0 to 10
#3 Updated by Anonymous 2018-04-06 12:55:49
- Subject changed from Allow Weblate to commit only po files to Create hooks to be implemented on the Weblate instance
I want to keep a backup of what we want to have / test on the Weblate instance / docker image.
This is the current status.
Weblate instance: Allow Weblate to commit only po files
https://labs.riseup.net/code/issues/15401#note-1
# .git/hooks/pre-commit
#!/bin/sh
# Disallow committing changes that did not happen on po files.
# Pre commit hook for weblate instance.
if ! git diff --quiet --name-only --exit-code -- . ':(exclude)*.po'
then
echo >&2 "Error: Cannot commit! The repository contains files that are not *. po files."
git diff --name-only --exit-code -- . ':(exclude)*.po' >&2
fi
Weblate instance: Create .gitattributes with merge strategy for po files
https://0xacab.org/Hefee/merge-po/blob/master/git-merge-po.sh (no pot file generation is done ATM)
better use the original first:
https://github.com/mezis/git-whistles/blob/master/libexec/git-merge-po.sh
- .gitattributes
Weblate instance: on pull from main → recreate pot files
- TODO: make this into a recursive script or make this part of a recursive script.
(We will be using a language activated on the production website to reverse engineer a pot file from a po file, so that we don’t have to rebuild the entire wiki everytime.):msghack --empty <name>.fr.po > <name>.pot
We can then use this pot file in git-merge-po for additional checks and improve the automatic merge strategy.
Weblate instance: on pull from main → update non activated languages
- TODO
Update all languages that are non activated on the production using the new created pot file.
So we get updates from *.mwdn files. Before updating the po files, we should ask Weblate to writeout everything to file.
Because we also need to manage file moves.
Weblate instance: on pull from main → update Weblate components
(check for added, deleted or moved mdwn files outside of wiki/src/contribute which is not translated)
- TODO
local, Weblate, remote: Run check_po whenever we try to commit a po file in all Git repositories
# .gitattributes
#!/bin/sh
# If we try to commit po files, check that they do not contain errors.
if ! git diff --ignore-submodules --name-only --exit-code -- . '*.po' \
&& ! ./wiki/src/contribute/l10n_tricks/check_po.sh
then
echo >&2 "The po files you're trying to commit contain errors. Please fix them and try again."
fi
TODO
- TODO: puppetize these hooks and add them to production and docker:
https://0xacab.org/drebs/tails-translate-docker
#4 Updated by Anonymous 2018-06-19 10:44:42
Current status of this ticket:
- we should make sure that Weblate is configured to honor the rules we want to apply in unify_po-headers.sh (I’ll configure this in the admin interface.)
- we might need to run unify_po-headers.sh (to be tested!)
- we need to run check_po.sh on every push on Weblate (to be tested!)
- we need to add our pre-commit hook to Git (to be tested!)
- we need to implement and activate our merge strategy on this machine (to be tested!)
- we need to make sure that all cronjobs are running
- we need to make sure we receive an email when any of this fails.
#5 Updated by Anonymous 2018-11-02 17:54:19
- Assignee set to hefee
#6 Updated by hefee 2018-11-05 17:20:26
- related to
Bug #15402: update hook for Main git when handling push from weblate added
#7 Updated by hefee 2019-02-08 22:59:32
- Status changed from In Progress to Rejected
u wrote:
> Current status of this ticket:
>
> - we should make sure that Weblate is configured to honor the rules we want to apply in unify_po-headers.sh (I’ll configure this in the admin interface.)
> - we might need to run unify_po-headers.sh (to be tested!)
not anymore. We checked the last couple of months of commits by weblate and they are totally fine.
> - we need to run check_po.sh on every push on Weblate (to be tested!)
not needed (see above)
> - we need to add our pre-commit hook to Git (to be tested!)
as we removed the rule to unify po files, we also do not need this pre-commit hook.
> - we need to implement and activate our merge strategy on this machine (to be tested!)
done
> - we need to make sure that all cronjobs are running
done
> - we need to make sure we receive an email when any of this fails.
done - I’ll get often mails if cronjobs fails…
#8 Updated by intrigeri 2019-06-27 17:16:55
- Assignee deleted (
hefee)