Launching po editor is optional
ci/woodpecker/pr/woodpecker Pipeline was successful
Details
ci/woodpecker/pr/woodpecker Pipeline was successful
Details
removed simple git diff in favor of textconv variant
This commit is contained in:
parent
e845e43847
commit
2505128f8e
|
@ -1,17 +1,39 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
_usage() {
|
||||||
|
echo "Usage: $0 [-n] PO_FILE"
|
||||||
|
echo "Ease the correction of fuzzies inserted by merge commits"
|
||||||
|
echo
|
||||||
|
echo "-n, --no-edit do not launch po editor"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
LAUNCH_EDIT=1
|
||||||
|
if [[ $# -eq 2 ]]; then
|
||||||
|
if [[ $1 -eq "-n" ]] || [[ $1 -eq "--no-edit" ]]; then
|
||||||
|
LAUNCH_EDIT=0
|
||||||
|
else
|
||||||
|
_usage
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $# -ne 1 ]]; then
|
if [[ $# -ne 1 ]]; then
|
||||||
echo "usage: $0 PO_FILE"
|
_usage
|
||||||
echo "Ease the correction of fuzzies inserted by merge commits"
|
fi
|
||||||
exit
|
|
||||||
|
if [[ ! -f $1 ]]; then
|
||||||
|
echo "$1: file not found"
|
||||||
|
_usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Temp directory to filter files before display
|
# Temp directory to filter files before display
|
||||||
TMP_DIR=$(mktemp -d /tmp/fuzzy_diff.XXXXXX || exit 1)
|
TMP_DIR=$(mktemp -d /tmp/fuzzy_diff.XXXXXX || exit 1)
|
||||||
trap 'rm --force --recursive "$TMP_DIR"' EXIT
|
trap 'rm --force --recursive "${TMP_DIR}"' EXIT
|
||||||
|
|
||||||
|
|
||||||
PO_EDITOR=$(which poedit)
|
PO_EDITOR=poedit
|
||||||
DIFFTOOL=$(git config diff.tool)
|
DIFFTOOL=$(git config diff.tool)
|
||||||
PO_FILE=$1
|
PO_FILE=$1
|
||||||
|
|
||||||
|
@ -21,20 +43,18 @@ FUZZY_REVS=$(git log --oneline -S '#, fuzzy' ${PO_FILE} | \
|
||||||
grep -i 'merge' | \
|
grep -i 'merge' | \
|
||||||
awk '{ print $1 }')
|
awk '{ print $1 }')
|
||||||
|
|
||||||
{PO_EDITOR} ${PO_FILE} 2>/dev/null &
|
if [[ ${LAUNCH_EDIT} -eq 1 ]]; then
|
||||||
|
${PO_EDITOR} "${PO_FILE}" 2>/dev/null &
|
||||||
|
fi
|
||||||
|
|
||||||
for sha in ${FUZZY_REVS} ; do
|
for sha in ${FUZZY_REVS} ; do
|
||||||
# show the diff between parent rev and fuzzy rev
|
|
||||||
|
|
||||||
# simple version which includes all modifications
|
|
||||||
#git difftool --no-prompt ${sha}^ ${sha} -- ${PO_FILE}
|
|
||||||
|
|
||||||
# filter files à la mode textconv
|
# filter files à la mode textconv
|
||||||
git show ${sha}:${PO_FILE} | grep -v -e '^#:' -e '^"PO' > ${TMP_DIR}/right.po
|
git show ${sha}:${PO_FILE} | grep -v -e '^#:' -e '^"PO' > ${TMP_DIR}/right.po
|
||||||
git show ${sha}^:${PO_FILE} | grep -v -e '^#:' -e '^"PO' > ${TMP_DIR}/left.po
|
git show ${sha}^:${PO_FILE} | grep -v -e '^#:' -e '^"PO' > ${TMP_DIR}/left.po
|
||||||
${DIFFTOOL} ${TMP_DIR}/left.po ${TMP_DIR}/right.po
|
"${DIFFTOOL}" ${TMP_DIR}/left.po ${TMP_DIR}/right.po
|
||||||
done
|
done
|
||||||
|
|
||||||
# clean up temp directory
|
# clean up temp directory
|
||||||
rm --force --recursive "$TMP_DIR"
|
rm --force --recursive "${TMP_DIR}"
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue