Switching to Git

Tanguy Ortolo tanguy+debian at ortolo.eu
Sun Feb 24 12:36:22 UTC 2013


Joost van Baal-Ilić, 2013-02-24 12:37+0100:
>Yes, exactly.  Translations have a comment indicating which version of the
>english original they claim to be a translation of.

Oh, I see. And this version happens to be a CVS revision number too. 
Well, that will have to be adapted somehow, because Git has no 
meaningful revision numbers, only SHA-1 hashes of each commit. The 
easiest thing I can think of to get something vaguely equivalent is to 
use dates instead, or possibly manually-defined Git commits but that 
would require a bit more work.

>I'd prefer something else:
>
>> Joost van Baal-Ilić, 2013-02-24 07:34+0100:
>>> translation-check.pl comes from the Debian website code.  The
>>> www-team likely has a reimplementation.  We should look around for such a thing
>>> there.
>>>
>>> Check how the www-team does check for
>>> up-to-date-ness of translations, and copy their code (assuming it works with
>>> git).
>
>Do you have time to search for the script the www-team uses to handle this?
>Imho it'd be a waste if we'd implement exactly the same functionality in yet another
>way.

Oh, I have found it 
<http://anonscm.debian.org/viewvc/webwml/webwml/check_trans.pl?revision=1.92&view=markup>, 
only it is written in Perl and adapting it, or even understanding it, 
would require me to learn Perl first (I already tried to learn some 
basic Perl, but as I did not like it I carefully avoided any occasion to 
use that knowledge so now I am back at the beginning, knowing almost 
nothing of that language…).


On the other side, doing something as simple as:
1. looking on a file to get the {revision, tag, date, whatever 
    appropriate} of the original it claims to be a translation of;
2. getting the last {revision, tag, date, whatever appropriate} 
    of that original;
3. printing a warning if the value at 1. is inferior to the one at 2.
is really trivial if we choose an appropriate revision identifier. For 
instance, with date, that would only require something like:

     #! /bin/sh

     original="$1"
     translation="$2"

     # get date of last commit of $original
     original_date=$(git log -1 --format=format:'%ad' --date=iso "$original")

     # get date of last commit of $original that was use for $translation
     # look for line “% translation-check DATE” in $translation
     translation_date=$(
         grep -F translation-check "$translation" \
             | { read comment marker translation_date ;
                 printf '%s' "$translation_date" ; }
     )

     # convert both dates to epoch for comparison
     original_date_epoch=$(date -d "$original_date" '+%s')
     translation_date_epoch=$(date -d "$translation_date" '+%s')

     # compare both dates and print a warning if the translation is 
     # outdated
     if [ "$original_date_epoch" -gt "$translation_date_epoch" ]
     then
         prinf 'Translation %s (%s) of %s (%s) is outdated.\n' \
             "$translation" "$translation_date" \
             "$original" "$original_date"
     fi


It could even be simplified with the following hypothese:
     When someone does a translation, he uses the last version of the 
     original.

With that hypotheses, there is not need to indicate in each translation 
what version of the original it is based on, since it is simply {the 
last one that was available when that translation was made}. And the 
comparison to determine whether or not the translation is up-to-date 
simply becomes: is the last commit the modified the translation more 
recent than the last commit that modified the original? Or, in shell:

original_date=$(git log -1 --format=format:'%ad' --date=iso "$original")
     translation_date=$(git log -1 --format=format:'%ad' --date=iso "$translation")
     original_date_epoch=$(date -d "$original_date" '+%s')
     translation_date_epoch=$(date -d "$translation_date" '+%s')
     if [ "$original_date_epoch" -gt "$translation_date_epoch" ]
     then
         …
     fi

-- 
Tanguy Ortolo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/debian-flyers-devel/attachments/20130224/494f44f4/attachment.pgp>


More information about the debian-flyers-devel mailing list