forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckDeletedTxt.sh
executable file
·46 lines (41 loc) · 1.52 KB
/
checkDeletedTxt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 --find-renames $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