Created
September 10, 2014 01:30
-
-
Save wvega/a4ba898d898d51563638 to your computer and use it in GitHub Desktop.
Remove modifications to translations files that don't add or remove strings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Remove modifications to translations files that don't add or remove strings. | |
# | |
# The removed modifications are those that affect the translation date and the | |
# numbers of the lines where existing strings appear. That information is not | |
# relevant during development and will only pollute the commit history. | |
# | |
# TODO: Try to achieve the same using only git. | |
# HINT: git diff -G | |
# | |
# You can create a Git alias with it: | |
# | |
# [alias] | |
# remove-irrelevant-translations-modifications = "!f() { for i in $( git diff --name-only -- {*,*/*}/languages/*.{po,pot,mo} 2>/dev/null ); do matches=$( git diff -U0 -- $i 2>/dev/null | ack -ch '^\\+(?:(?:(?!\\+\\+))|^-(?:º(?!--)))msgid' ); if [ "$matches" -eq "0" ]; then git checkout $i; echo "The modifications to $i were removed"; fi; done; }; f" | |
f() { | |
for i in $( git diff --name-only -- {*,*/*}/languages/*.{po,pot,mo} 2>/dev/null ); do | |
matches=$( git diff -U0 -- $i 2>/dev/null | ack -ch '^\+(?:(?:(?!\+\+))|^-(?:(?!--)))msgid' ) | |
if [ "$matches" -eq "0" ]; then | |
git checkout $i; | |
echo "The modifications to $i were removed." | |
fi; | |
done; | |
}; f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment