2 # -*- coding: utf-8 -*-
4 # Dieses Skript erzeugt Differenzbilder (diff) für die
5 # Patgen-Eingabelisten zwischen zwei angegebenen Commits. Wird nur ein
6 # Commit angegeben, wird als Zielcommit "master" verwendet. Die
7 # Ausgabedateien werden als Dateien
9 # dehyph*-x/<Start-Commit-Hash>-<Ziel-Commit-Hash>.diff
11 # in Verzeichnissen gespeichert, die der jeweiligen Rechtschreibung
12 # entsprechen. Start- und Ziel-Commit können in jeder gültigen
13 # Git-Syntax angegeben werden. Für die Dateinamen werden die
14 # entsprechenden abgekürzten alphanumerischen Commit-Hashes
17 # Aufruf: sh patgen-list-diff.sh <start commit> [<ziel commit>]
20 # Eingabe: <start commit> Ein Start-Commit.
21 # <ziel commit> Ein optionaler Ziel-Commit.
24 # dehyphn-x/<hashes>.diff Differenzbild refromierte Rechtschreibung
25 # dehypht-x/<hashes>.diff Differenzbild traditionelle Rechtschreibung
26 # dehyphts-x/<hashes>.diff Differenzbild traditionelle Rechtschreibung
31 echo 'usage: patgen-list-diff <start commit> [<target commit>]'
32 echo 'Create diffs for patgen input lists between <start commit> and'
33 echo '<target commit> (by default "master") and save them as files'
34 echo 'dehyph*-x/<start commit hash>-<target commit hash>.diff in'
35 echo 'directories corresponding to the spelling.'
45 typeset GITDATA
=`git log -1 --format=%ci-%H $FROMCOMMIT --`
46 FROMDATE
=${GITDATA:0:10}+${GITDATA:11:2}-${GITDATA:14:2}-${GITDATA:17:2}
47 FROMHASH
=${GITDATA:26}
50 echo 'patgen-list-diff.sh: error identifying start commit hash: ' $FROMCOMMIT
53 typeset GITDATA
=`git log -1 --format=%ci-%H $TOCOMMIT --`
54 TODATE
=${GITDATA:0:10}+${GITDATA:11:2}-${GITDATA:14:2}-${GITDATA:17:2}
58 echo 'patgen-list-diff.sh: error identifying target commit hash: ' $TOCOMMIT
64 # Function definition. If not already present, place a copy of a
65 # commit's working copy in a directory 'wl-<commit hash>'.
67 typeset commit
=$1 commitdate
=$2
68 typeset commitdir
=$commitdate-$commit
69 if test ! -d $commitdir
71 git archive
--format=tar --prefix=$commitdir/ $commit |
tar xf
-
75 # Function definition.
76 create_patgen_list
() {
77 typeset commit
=$1 commitdate
=$2 patgenlist
=$3
78 typeset commitdir
=$commitdate-$commit
79 echo "Making ${commit:0:7} file $patgenlist."
80 if test ! -e $commitdir/$patgenlist
82 # 'make -C $commitdir $patgenlist' doesn't work reliably on Git
84 (cd $commitdir && make $patgenlist > /dev
/null
)
88 # Function definition.
90 typeset fromcommit
=$1 fromcommitdate
=$2 tocommit
=$3 tocommitdate
=$4 dehyph
=$5 spell
=$6
91 typeset fromcommitdir
=$fromcommitdate-$fromcommit tocommitdir
=$tocommitdate-$tocommit patgenlist
=$dehyph/words.hyphenated.
$spell difffile
=${fromcommit:0:7}-${tocommit:0:7}.
diff
92 create_patgen_list
$fromcommit $fromcommitdate $patgenlist
93 create_patgen_list
$tocommit $tocommitdate $patgenlist
94 if test ! -d $dehyph; then mkdir
$dehyph; fi
95 diff $fromcommitdir/$patgenlist $tocommitdir/$patgenlist > $dehyph/$difffile
96 gawk
-f patgen-list-diff.
awk -v ftr
=daten
/german.
tr $dehyph/$difffile
101 echo "Diff'ing patgen input files."
102 printf "from: %7s %10s %s\n" ${FROMHASH:0:7} ${FROMDATE:0:10} $FROMCOMMIT
103 printf "to: %7s %10s %s\n" ${TOHASH:0:7} ${TODATE:0:10} $TOCOMMIT
104 # Get commit's working copies.
105 get_working_copy
$FROMHASH $FROMDATE
106 get_working_copy
$TOHASH $TODATE
107 # Write header to summary table file.
108 PLDTABLE
=CHANGES.table.txt
109 echo " Rechtschreibung hinzugefügt entfernt korrigiert" > $PLDTABLE
110 echo " ---------------------------------------------------------------" >> $PLDTABLE
111 # Diff patgen lists and write results to summary table file.
112 echo -n " traditionell (DE, AT)" >> $PLDTABLE
113 diff_patgen_list
$FROMHASH $FROMDATE $TOHASH $TODATE dehypht-x trad
114 echo -n " traditionell (CH) " >> $PLDTABLE
115 diff_patgen_list
$FROMHASH $FROMDATE $TOHASH $TODATE dehyphts-x swiss
116 echo -n " reformiert " >> $PLDTABLE
117 diff_patgen_list
$FROMHASH $FROMDATE $TOHASH $TODATE dehyphn-x refo