-
Notifications
You must be signed in to change notification settings - Fork 45
/
test
executable file
·81 lines (72 loc) · 2.11 KB
/
test
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
if [ "$TRAVIS_BRANCH" = "master" ]; then
elixir --no-halt stats.exs -s python \
-s commonlisp \
-s ruby \
-s haskell \
-s go \
-s php \
-s elixir \
-s lua \
-s c++ \
-s bash \
-s clojure \
-s c \
-q
exit $?
else # Cancel build if travis is building pushed version
echo "Skipped this build"
exit 0
fi
fi
# only return the arguments which are files that exists on the filesystem
function filter_exists {
while read line; do
[[ -f "$line" ]] && echo $line
done
}
function diff_files () {
# Return uncommited changes file names
git diff origin/master --name-only | filter_exists
}
function staged_files () {
# Return staged file names
git diff --cached --name-only | filter_exists
}
function build_commited () {
# Build only commited changed
diff_files | xargs python3 stats.py --build --files
}
function build_staged () {
# Build only staged files
#NOTE: Run before opening PR on your machine, make sure
# `git add .`
staged_files | xargs python3 stats.py --build --files
}
function main () {
status=0
mode=$1
target=$2
if [ "$mode" = "" ]; then
build_commited
status=$?
elif [ "$mode" = "async" ]; then
#TODO: stats.exs --build --files
echo "Not Implemented"
status=1
elif [ "$mode" = "sync" ]; then
if [ "$target" = "diff" ]; then
build_commited
status=$?
elif [ "$target" = "staged" ]; then
build_staged
status=$?
fi
else
echo "Usage : $0 [sync|async] [diff|staged]"
status=1
fi
exit $status
}
main $@