File tree 1 file changed +66
-0
lines changed
1 file changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+
4
+ _usage () {
5
+ echo " Usage: $0 [-n] PO_FILE"
6
+ echo " Ease the correction of fuzzies inserted by merge commits"
7
+ echo
8
+ echo " -n, --no-edit do not launch po editor"
9
+ exit
10
+ }
11
+
12
+ LAUNCH_EDIT=1
13
+ if [ $# -eq 2 ]; then
14
+ if [ " $1 " -eq " -n" ] || [ " $1 " -eq " --no-edit" ]; then
15
+ LAUNCH_EDIT=0
16
+ else
17
+ _usage
18
+ fi
19
+ shift
20
+ fi
21
+
22
+ if [ $# -ne 1 ]; then
23
+ _usage
24
+ fi
25
+
26
+ if [ ! -f " $1 " ]; then
27
+ echo " $1 : file not found"
28
+ _usage
29
+ fi
30
+
31
+ # Temp directory to filter files before display
32
+ TMP_DIR=$( mktemp -d /tmp/fuzzy_diff.XXXXXX || exit 1)
33
+ trap ' rm --force --recursive "${TMP_DIR}"' EXIT
34
+
35
+
36
+ PO_EDITOR=poedit
37
+ DIFFTOOL=$( which $( git config diff.tool) )
38
+
39
+ if [ ! -x " $DIFFTOOL " ]; then
40
+ echo " git diff.tool seems not configured"
41
+ _usage
42
+ fi
43
+
44
+ PO_FILE=$1
45
+
46
+ # search for revs where fuzzy was added or suppressed
47
+ # and filter where commit message contains 'merge'
48
+ FUZZY_REVS=$( git log --oneline -S ' #, fuzzy' ${PO_FILE} | \
49
+ grep -i ' merge' | \
50
+ awk ' { print $1 }' )
51
+
52
+ if [ ${LAUNCH_EDIT} -eq 1 ]; then
53
+ ${PO_EDITOR} " ${PO_FILE} " 2> /dev/null &
54
+ fi
55
+
56
+ for sha in ${FUZZY_REVS} ; do
57
+ # filter files à la mode textconv
58
+ git show ${sha} :${PO_FILE} | grep -v -e ' ^#:' -e ' ^"PO' > ${TMP_DIR} /right.po
59
+ git show ${sha} ^:${PO_FILE} | grep -v -e ' ^#:' -e ' ^"PO' > ${TMP_DIR} /left.po
60
+ " ${DIFFTOOL} " ${TMP_DIR} /left.po ${TMP_DIR} /right.po
61
+ done
62
+
63
+ # clean up temp directory
64
+ rm --force --recursive " ${TMP_DIR} "
65
+ trap - EXIT
66
+
You can’t perform that action at this time.
0 commit comments