Project

General

Profile

Bug #15401

Feature #10034: Translation web platform

Feature #15079: Integrate the platform with our Git and ikiwiki infrastructure

Create hooks to be implemented on the Weblate instance

Added by u over 1 year ago. Updated 5 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
03/13/2018
Due date:
% Done:

10%

Feature Branch:
Type of work:
Sysadmin
Blueprint:
Starter:
Affected tool:

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.

Related issues

Related to Tails - Bug #15402: update hook for Main git when handling push from weblate Resolved

History

#1 Updated by u over 1 year ago

#!/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 u over 1 year ago

  • Status changed from Confirmed to In Progress
  • % Done changed from 0 to 10

#3 Updated by u over 1 year ago

  • 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
  1. .gitattributes

Weblate instance: on pull from main → recreate pot files

  1. 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

  1. 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)

  1. 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
  1. TODO: puppetize these hooks and add them to production and docker:
    https://0xacab.org/drebs/tails-translate-docker

#4 Updated by u over 1 year ago

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 u about 1 year ago

  • Assignee changed from u to hefee

#6 Updated by hefee about 1 year ago

  • Related to Bug #15402: update hook for Main git when handling push from weblate added

#7 Updated by hefee 9 months ago

  • 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 5 months ago

  • Assignee deleted (hefee)

Also available in: Atom PDF