[Libreoffice-commits] core.git: bin/ui-checkdomain.sh .git-hooks/pre-commit

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 27 15:29:09 UTC 2021


 .git-hooks/pre-commit |   14 +++++++++++++
 bin/ui-checkdomain.sh |   52 --------------------------------------------------
 2 files changed, 14 insertions(+), 52 deletions(-)

New commits:
commit f3665d2a42b39814764f3eb9e20498b8a4be1d00
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Apr 27 11:31:04 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Apr 27 17:28:17 2021 +0200

    Check UI interface domains in the git pre-commit hook
    
    This will prevent bugs like tdf#141902 to happen
    
    Change-Id: If81164c704ec17d3fee044aaa0ec9c16d474009e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114705
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit
index 1f2e9307de01..578159e7c6e9 100755
--- a/.git-hooks/pre-commit
+++ b/.git-hooks/pre-commit
@@ -18,6 +18,11 @@ sub check_whitespaces($)
     my $src_limited = "c|cpp|cxx|h|hrc|hxx|idl|inl|java|swift|map|MK|pmk|pl|pm|sdi|sh|src|tab|ui|xcu|xml|xsl|py";
     my $src_full = "c|cpp|cxx|h|hrc|hxx|idl|inl|java|swift|map|mk|MK|pmk|pl|pm|sdi|sh|src|tab|ui|xcu|xml|xsl|py";
 
+    my %modules = (basctl=>'basctl', chart2=>'chart', cui=>'cui', dbaccess=>'dba', desktop=>'dkt', editeng=>'editeng',
+                   extensions=>'pcr', filter=>'flt', formula=>'"for"', fpicker=>'fps', framework=>'fwk', reportdesign=>'rpt',
+                   sc=>'sc', sd=>'sd', sfx2=>'sfx', starmath=>'sm', svtools=>'svt', svx=>'svx', sw=>'sw', uui=>'uui',
+                   vcl=>'vcl', writerperfect=>'wpt', xmlsecurity=>'xsc');
+
     my $found_bad = 0;
     my $filename;
     my $reported_filename = "";
@@ -137,6 +142,15 @@ sub check_whitespaces($)
             {
                 bad_line(".ui file without translation domain", $_, "ui");
             }
+            if (/<interface domain=/)
+            {
+                foreach my $key (keys %modules) {
+                    if ((rindex($filename, $key, 0) == 0) and not (/$modules{$key}/))
+                    {
+                        bad_line("interface domain should be '$modules{$key}'", $_, "ui");
+                    }
+                }
+            }
         }
     }
     if ( $found_bad)
diff --git a/bin/ui-checkdomain.sh b/bin/ui-checkdomain.sh
deleted file mode 100755
index 30e0c5b0f594..000000000000
--- a/bin/ui-checkdomain.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# This script finds .ui files with incorrect translation domain set
-# and prints the domain, the file name and the expected domain
-# See also the discussion at https://gerrit.libreoffice.org/#/c/72973/
-
-declare -A modules
-
-# List of modules with .ui files and their expected translation domain
-modules+=(  \
-            [basctl]=basctl \
-            [chart2]=chart \
-            [cui]=cui \
-            [dbaccess]=dba \
-            [desktop]=dkt \
-            [editeng]=editeng \
-            [extensions]=pcr \
-            [filter]=flt \
-            [formula]="for" \
-            [fpicker]=fps \
-            [framework]=fwk \
-            [reportdesign]=rpt \
-            [sc]=sc \
-            [sd]=sd \
-            [sfx2]=sfx \
-            [starmath]=sm \
-            [svtools]=svt \
-            [svx]=svx \
-            [sw]=sw \
-            [uui]=uui \
-            [vcl]=vcl \
-            [writerperfect]=wpt \
-            [xmlsecurity]=xsc \
-)
-
-# Iterate the keys, i.e. modules with a uiconfig subdir
-for key in ${!modules[@]}; do
-    # Enumerate all .ui files in each module
-    for uifile in $(git ls-files ${key}/uiconfig/*\.ui); do
-        # Check that they contain the expected domain in double quotation marks, print the line if they don't
-        grep "\<interface domain=" $uifile | grep -v "\"${modules[${key}]}\"";
-        if [ "$?" -eq 0 ] ;
-            # Report the file name and the expected domain
-            then echo "^Problematic interface domain in file: $uifile ; should be: "${modules[${key}]}"";
-        fi
-    done
-done


More information about the Libreoffice-commits mailing list