]>
Commit | Line | Data |
---|---|---|
5d25b781 KZ |
1 | #!/bin/bash |
2 | # | |
3 | # git-tp-sync - downloads the latest PO files from translationproject.org | |
4 | # and commits changes to your GIT repository. | |
5 | # | |
6 | # Features: | |
7 | # - commit per PO file (no more huge commits for all .po files) | |
8 | # - the commit "Author:" field is set according to the Last-Translator | |
9 | # | |
10 | # Copyright (C) 2007-2016 Karel Zak <kzak@redhat.com> | |
11 | # | |
12 | # This file is free software; you can redistribute it and/or modify | |
13 | # it under the terms of the GNU General Public License as published by | |
14 | # the Free Software Foundation; either version 2 of the License, or | |
15 | # (at your option) any later version. | |
16 | # | |
17 | # This file is distributed in the hope that it will be useful, | |
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | # GNU General Public License for more details. | |
21 | # | |
22 | ||
23 | PROJECT="util-linux" | |
24 | if [ -n "$1" ]; then | |
25 | while (( "$#" )); do | |
26 | if [ -n "$1" ]; then | |
27 | rsync -Lrtvz rsync://translationproject.org/tp/latest/$PROJECT/$1.po po | |
28 | fi | |
29 | shift | |
30 | done | |
31 | else | |
32 | rsync -Lrtvz rsync://translationproject.org/tp/latest/$PROJECT/ po | |
33 | fi | |
34 | ||
35 | PO_NEW=$(git ls-files -o | gawk '/po\/[[:alpha:]_\-]*\.po/ { sub("po/", ""); print $0; }' | sort) | |
36 | PO_MOD=$(git ls-files -m | gawk '/po\/[[:alpha:]_\-]*\.po/ { sub("po/", ""); print $0; }' | sort) | |
37 | ||
38 | function get_author { | |
39 | echo $(gawk 'BEGIN { FS=": " } /Last-Translator/ { sub("\\\\n\"", ""); print $2 }' "$1") | |
40 | } | |
41 | ||
42 | function do_commit { | |
43 | local POFILE="$1" | |
44 | local MSG="$2" | |
45 | local AUTHOR=$(get_author "$POFILE") | |
46 | ||
47 | git commit --author "$AUTHOR" -m "$MSG" "$POFILE" | |
48 | } | |
49 | ||
50 | for f in $PO_MOD; do | |
51 | do_commit "po/$f" "po: update $f (from translationproject.org)" | |
52 | done | |
53 | ||
54 | for f in $PO_NEW; do | |
55 | git add "po/$f" | |
56 | do_commit "po/$f" "po: add $f (from translationproject.org)" | |
57 | done | |
58 |