git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jiang Xin <worldhello.net@gmail.com>
Cc: Git List <git@vger.kernel.org>, avarab@gmail.com
Subject: Re: [PATCH] Maintaince script for l10n files and commits
Date: Thu, 08 Mar 2012 12:41:16 -0800	[thread overview]
Message-ID: <7v399iddw3.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1331222706-81728-1-git-send-email-worldhello.net@gmail.com> (Jiang Xin's message of "Fri, 9 Mar 2012 00:05:06 +0800")

Jiang Xin <worldhello.net@gmail.com> writes:

> Usage of this script:
>
>  * po-helper.sh XX.po   : Init or update XX.po from git.pot
>
>  * po-helper.sh check [XX.po]
>                         : Perform all the checks for XX.po
>
>  * po-helper.sh commits [since] [til]
>                         : Check non-ascii chars in commit logs
>
>                           Don't write commit log with non-ascii chars
>                           without proper encoding settings.
>
>                           Subject of commit log must written in English.
>
>                           Don't change files outside this directory (po/)
>
>  * po-helper.sh pot     : Display summary of updates of git.pot file

That's quite a style deviation from out norm in the commit log
messages, don't you think (see "git log --no-merges -100", for
example)?  State the problem you are attempting to solve first, and
explain the solution to the problem, in separate paragraphs for
readability, perhaps like this:

	There are routine tasks translators need to perform that can
	be automated.

	Help them to

         (1) initialize or update the message files;
         (2) check errors in the message files they edited;
         (3) check errors in their commits; and
         (4) review recent updates to the message template file
             they base their translations on.

        by adding a helper script.

> Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
> ---
>  po/po-helper.sh |  271 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 271 insertions(+)
>  create mode 100755 po/po-helper.sh
>
> diff --git a/po/po-helper.sh b/po/po-helper.sh
> new file mode 100755
> index 0000000..dd370a5
> --- /dev/null
> +++ b/po/po-helper.sh
> @@ -0,0 +1,271 @@
> +#!/bin/bash

Is there any bash-ism in this script?  Otherwise please start this
with "#!/bin/sh" to allow people who do not use bash to get involved
in the project.

> +#
> +# Copyright (c) 2012 Jiang Xin
> +
> +POTFILE=git.pot
> +
> +usage()
> +{

Style:

	usage () {

In general, it is safe to mimic the style "git-am.sh" is written in,
although some crufts seem to have slipped in with recent updates.

> +    cat <<-END_OF_USAGE

Style: unless you have substitutions ($var etc.) inside the here
text, please quote the end token to make it clear that readers do
not have to scan and look for what is substituted, i.e.

	cat <<-\END_OF_USAGE

> +Maintaince script for l10n files and commits.
> +
> +Usage:
> +
> + * po-helper.sh XX.po   : Init or update XX.po from git.pot

Will we later regret that we didn't give a command word for this
one?  Two common sources of such risks are:

 (1) it turns out XX.po matches the pattern we would want to use as
     a command; and

 (2) it turns out "init/update" is not the most often used action.

I do not think (1) is likely. I do not think anybody can decide
about (2) at this point yet.

> + * po-helper.sh check [XX.po]
> +                        : Perform all the checks for XX.po
> +
> + * po-helper.sh commits [since] [til]
> +                        : Check non-ascii chars in commit logs
> +
> +                          Don't write commit log with non-ascii chars
> +                          without proper encoding settings.
> +
> +                          Subject of commit log must written in English.
> +
> +                          Don't change files outside this directory (po/)
> +
> + * po-helper.sh pot     : Display summary of updates of git.pot file
> +
> +END_OF_USAGE

Do you really want the blank line output at the end?

> +
> +    exit 1
> +}
> +
> +# Display summary of updates of git.pot
> +show_pot_update_summary()
> +{
> +    pnew="^.*:([0-9]+): this message is used but not defined in"
> +    pdel="^.*:([0-9]+): warning: this message is not used"
> +    new_count=0
> +    del_count=0
> +    new_lineno=""
> +    del_lineno=""
> +
> +    status=$(git status --porcelain -- $POTFILE)
> +    if [ -z "$status" ]; then
> +        echo "Nothing changed."
> +    else
> +        tmpfile=$(mktemp /tmp/git.po.XXXX)
> +        LANGUAGE=C git show HEAD:./git.pot > $tmpfile
> +        LANGUAGE=C msgcmp -N --use-untranslated $tmpfile $POTFILE 2>&1 |
> +        {    while read line; do
> +                if [[ $line =~ $pnew ]]; then

That sounds like a blatant bash-ism to me.

> +...
> +}
> +
> +# Syntax check on XX.po, or all .po files if nothing provided
> +check_po()
> +{
> +    if [ $# -eq 0 ]; then
> +        ls *.po | while read f; do
> +            echo "============================================================"

Style:

	if test $# = 0
        then
		ls *.po |
		while read f
		do
                	...

Also indentation is done with HT, not runs of SP.

> +# Create or update XX.po file from git.pot
> +create_or_update_po()
> +{
> +    if [ $# -eq 0 ]; then
> +        usage
> +    fi
> +    while [ $# -gt 0 ]; do
> +        po=$1
> +        shift
> +        if [ -f $po ]; then
> +            msgmerge --add-location --backup=off -U $po $POTFILE
> +        else
> +            msginit -i $POTFILE --locale=${po%.po}
> +            perl -pi -e 's/(?<="Project-Id-Version: )PACKAGE VERSION/Git/' $po

Ah ;-) show_pot_update_summary() can be written so that this script
does not have to rely on bash-ism at all, as you are going to use
Perl anyway.

> +verify_commit_encoding()
> +{
> ...
> +}

I am not sure if the protection these checks offer is worth the
complexity of the script, but it is primarily to reduce back and
forth between the l10n coordinator and the language teams, so I
won't complain.

> +# vim: et ts=4 sw=4

I prefer not to see scripts forcing author's personal preference.
Especially, wouldn't ts=4 make it hard to avoid indenting with runs
of spaces by mistake?

  reply	other threads:[~2012-03-08 20:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 18:47 [PATCH] Maintaince script for l10n files and commits Jiang Xin
2012-03-07 19:17 ` Junio C Hamano
2012-03-08 16:05   ` Jiang Xin
2012-03-08 20:41     ` Junio C Hamano [this message]
2012-03-09  0:57       ` Jiang Xin
2012-03-09  6:08       ` [PATCH v2] " Jiang Xin
2012-03-09  6:20         ` David Aguilar
2012-03-09  6:31           ` Jiang Xin
2012-03-10  0:40         ` Junio C Hamano
2012-03-10  9:17       ` [PATCH v3] " Jiang Xin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v399iddw3.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=worldhello.net@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).