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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#!/bin/bash
#
# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
#
# Runs pocketlint on files changed from parent branch.
${shell-relative-path-setup}
utilitiesdir=${buildout:directory/utilities|shell-path}
[ -z "$utilitiesdir" ] && utilitiesdir=.
if [ -z "$1" ]; then
# No command line argument provided, lint all changed files.
files=$($utilitiesdir/find-changed-files.sh)
else
# Add newlines so grep filters out pyfiles correctly later.
files=`echo $* | tr " " "\n"`
fi
echo "= Launchpad lint ="
echo ""
echo "Checking for conflicts and issues in changed files."
if [ -z "$files" ]; then
echo "No changed files detected."
exit 0
else
echo
echo "Linting changed files:"
for file in $files; do
echo " $file"
done
fi
# Are there patches to the schema or changes to current.sql?
sample_dir="database/sampledata"
current_sql="$sample_dir/current.sql"
current_dev_sql="$sample_dir/current-dev.sql"
lintdata_sql="$sample_dir/lintdata.sql"
lintdata_dev_sql="$sample_dir/lintdata-dev.sql"
database_changes=$(echo $files | sed '/database.*\(patch-\|current\)/!d')
if [ -n "$database_changes" ]; then
make -C database/schema lintdata > /dev/null
sql_diff=$(diff -q "$current_sql" "$lintdata_sql")
if [ -z "$sql_diff" ]; then
rm $lintdata_sql
fi
sql_dev_diff=$(diff -q "$current_dev_sql" "$lintdata_dev_sql")
if [ -z "$sql_dev_diff" ]; then
rm $lintdata_dev_sql
fi
else
sql_diff=""
sql_dev_diff=""
fi
karma_bombs=`sed '/INTO karma /!d; /2000-/d; /2001-/d' $current_sql`
echo_sampledata_changes () {
echo " $2 differs from $1."
echo " Patches to the schema, or manual edits to $1"
echo " do not match the dump of the $3 database."
echo " If $2 is correct, copy it to"
echo " $1."
echo " Otherwise update $1 and run:"
echo " make schema"
echo " make newsampledata"
echo " cd $sample_dir"
echo " cp $4 $1"
echo " Run make schema again to update the test/dev database."
}
if [ -n "$sql_diff" -o -n "$sql_dev_diff" -o -n "$karma_bombs" ]; then
echo ""
echo ""
echo "== Schema =="
echo ""
fi
#
if [ -n "$sql_diff" -o -n "$karma_bombs" ]; then
echo "$current_sql"
fi
if [ -n "$sql_diff" ]; then
echo_sampledata_changes \
"$current_sql" "$lintdata_sql" "launchpad_ftest_template"\
"newsampledata.sql"
fi
if [ -n "$karma_bombs" ]; then
echo " Karma time bombs were added to sampledata."
echo " The Karma table has dates after 2002-01-01; either revise"
echo " them or remove rows if they are unneeded."
fi
if [ -n "$sql_dev_diff" ]; then
echo ""
echo "$current_sql"
echo_sampledata_changes \
"$current_dev_sql" "$lintdata_dev_sql" "launchpad_dev_template"\
"newsampledata-dev.sql"
fi
# Sample data contains auto generated files with long lines.
pocketlint_files=`echo "$files" | env -i grep -v ".sql$"`
if [ -z "$pocketlint_files" ]; then
exit 0
fi
echo ""
pocketlint $pocketlint_files 2>&1
|