Permalink
Please sign in to comment.
Browse files
Ci check deleted.txt when translators are deleted (#1238)
* ci: check translators for reused IDs * ci: check for deleted.txt consistency * Add multistr option to jshintrc * .ci/checkDeletedTxt.sh: Warn/exit if master not available Actually, this script will either be used in a local feature branch and then we can assume that master branch is also available, or in the Travis check of the official repo, where in each PR the master branch is available. In all other cases we skip now the test and show just a warning that we are doing that. * Add option to call checkTranslator.sh with label only
- Loading branch information...
Showing
with
112 additions
and 25 deletions.
- +14 −6 .ci/README.md
- +46 −0 .ci/checkDeletedTxt.sh
- +28 −18 .ci/checkTranslator.sh
- +21 −0 .ci/helper.sh
- +2 −1 .ci/jshintrc
- +1 −0 .travis.yml
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
source "$SCRIPT_DIR/helper.sh" | ||
cd "$SCRIPT_DIR" | ||
MASTER="master" | ||
BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
if [[ "$BRANCH" = "$MASTER" ]];then | ||
echo "${color_warn}skip${color_reset} - Can only check deleted.txt when not on '$MASTER' branch" | ||
exit 0 | ||
fi | ||
if ! git branch |grep -q "$MASTER"; then | ||
echo "${color_warn}skip${color_reset} - Can only check deleted.txt when '$MASTER' branch is also available for comparison" | ||
exit 0 | ||
fi | ||
main() { | ||
local IFS=$'\n' | ||
declare -a deletions=() | ||
local failed=0 | ||
# Find all deleted js files | ||
deletions+=($(git diff-index --diff-filter=D --name-only $MASTER|grep -v '\.ci'|grep 'js$')) | ||
if (( ${#deletions[@]} > 0 ));then | ||
for f in "${deletions[@]}";do | ||
local id=$(git show $MASTER:"$f"|grepTranslatorId) | ||
if ! grep -qF "$id" '../deleted.txt';then | ||
echo "${color_notok}not ok${color_reset} - $id ($f) should be added to deleted.txt" | ||
(( failed += 1)) | ||
fi | ||
done | ||
curVersion=$(head -n1 "../deleted.txt"|grep -o '[0-9]\+') | ||
origVersion=$(git show "$MASTER:deleted.txt"|head -n1|grep -o '[0-9]\+') | ||
if (( curVersion <= origVersion ));then | ||
echo "${color_notok}not ok${color_reset} - version in deleted.txt needs to be increased" | ||
(( failed += 1)) | ||
fi | ||
fi | ||
if [[ "$failed" = 0 ]];then | ||
echo "${color_ok}ok${color_reset} - deleted.txt" | ||
fi | ||
exit $failed | ||
} | ||
main |
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
if [[ -t 1 && "$(tput colors)" -gt 0 ]]; then | ||
export color_ok=$'\e[32;1m' | ||
export color_notok=$'\e[31;1m' | ||
export color_warn=$'\e[33m' | ||
export color_err=$'\e[31m' | ||
export color_reset=$'\e[0m' | ||
fi | ||
grepTranslatorId () { | ||
if [[ -n "$1" ]];then | ||
grep -r '"translatorID"' "$@" | sed -e 's/[" ,]//g' -e 's/^.*://g' | ||
else | ||
while read line;do | ||
echo "$line"|grep '"translatorID"' | sed -e 's/[" ,]//g' -e 's/^.*://g' | ||
done | ||
fi | ||
} | ||
# vim: ft=sh |
@@ -1,3 +1,4 @@ | ||
{ | ||
"laxbreak": true | ||
"laxbreak": true, | ||
"multistr": true | ||
} |
0 comments on commit
bb460b0