]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tools: add git-tp-sync-man
authorKarel Zak <kzak@redhat.com>
Mon, 7 Mar 2022 12:56:13 +0000 (13:56 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 7 Mar 2022 13:21:44 +0000 (14:21 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tools/Makemodule.am
tools/git-tp-sync-man [new file with mode: 0755]

index 50637421776ac11934b0d0b4be6d68fddf87ebd1..e9845adf56a03e9641786cd825a53d5dae5c7a7d 100644 (file)
@@ -1,6 +1,7 @@
 
 EXTRA_DIST += \
        tools/git-tp-sync \
+       tools/git-tp-sync-man \
        tools/git-version-gen \
        tools/ko-release-gen \
        tools/ko-release-push \
diff --git a/tools/git-tp-sync-man b/tools/git-tp-sync-man
new file mode 100755 (executable)
index 0000000..8a4f34f
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/bash
+#
+# Based on tools/git-tp-sync.
+# Copyright (C) 2007-2016 Karel Zak <kzak@redhat.com>
+#
+# TODO: merge git-tp-sync and git-tp-sync-man scripts.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+
+PROJECT="util-linux-man"
+if [ -n "$1" ]; then
+       while (( "$#" )); do
+               if [ -n "$1" ]; then
+                       rsync  -Lrtvz  rsync://translationproject.org/tp/latest/$PROJECT/$1.po po-man
+               fi
+               shift
+       done
+else
+       rsync  -Lrtvz  rsync://translationproject.org/tp/latest/$PROJECT/ po-man
+fi
+
+PO_NEW=$(git ls-files -o | gawk '/po-man\/[[:alpha:]_\-]*\.po/ { sub("po-man/", ""); print $0; }' | sort)
+PO_MOD=$(git ls-files -m | gawk '/po-man\/[[:alpha:]_\-]*\.po/ { sub("po-man/", ""); print $0; }' | sort)
+
+function get_author {
+       echo $(gawk 'BEGIN { FS=": " } /Last-Translator/ { sub("\\\\n\"", ""); print $2 }' "$1")
+}
+
+function do_commit {
+       local POFILE="$1"
+       local MSG="$2"
+       local AUTHOR=$(get_author "$POFILE")
+
+       git commit --author "$AUTHOR" -m "$MSG" "$POFILE"
+}
+
+for f in $PO_MOD; do
+       do_commit "po-man/$f" "po-man: update $f (from translationproject.org)"
+done
+
+for f in $PO_NEW; do
+       git add "po-man/$f"
+       do_commit "po-man/$f" "po-man: add $f (from translationproject.org)"
+done
+