-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvim_dev.sh
executable file
·64 lines (53 loc) · 1.38 KB
/
vim_dev.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# General functions
function failed_test_classes() {
grep -B 1 -E '(<error|<failure)' target/test-reports/TESTS-TestSuites.xml \
|grep -E '^ *<testcase' \
|sed -e 's/.* classname="//' \
|sed -e 's/".*//' \
|sort -u
}
function _editor_failed() {
if [ -r application.properties ]; then
editor="$1"
files=""
for classpath in `failed_test_classes`; do
class="${classpath/[0-9A-Za-z.]*\.}"
package="${classpath/.$class}"
new_files=`find . -name "${class}.groovy"`
files="$files $new_files"
done
if [ "$files" != "" ]; then
${editor} $files
fi
fi
}
function _editor_modified() {
editor="$1"
# if the current folder is in a git repo...
if (git status -s 2> /dev/null >/dev/null); then
# get a list of modified files that actually exist
modified_files=$(for foo in `git diff --relative --name-only HEAD^`; do if [ -e $foo ]; then echo $foo; fi; done)
echo "${editor} ${modified_files}"
echo ""
${editor} ${modified_files}
fi
}
# Editor specific implementations
function mvim_modified() {
_editor_modified mvim
}
function vim_modified() {
_editor_modified vim
}
function nvim_modified() {
_editor_modified nvim
}
function vim_failed() {
_editor_failed vim
}
function mvim_failed() {
_editor_failed mvim
}
function nvim_failed() {
_editor_failed nvim
}