File tree Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -1145,6 +1145,7 @@ def RepositoryName(self):
1145
1145
os .path .exists (os .path .join (current_dir , ".hg" )) or
1146
1146
os .path .exists (os .path .join (current_dir , ".svn" ))):
1147
1147
root_dir = current_dir
1148
+ break ;
1148
1149
current_dir = os .path .dirname (current_dir )
1149
1150
1150
1151
if (os .path .exists (os .path .join (root_dir , ".git" )) or
Original file line number Diff line number Diff line change 8
8
print >> sys .stderr , "Usage: filter_lint_by_diff.py diff.patch repository_root_directory < cpplint_warnings.txt"
9
9
sys .exit (1 )
10
10
11
- added_lines = set ()
12
11
repository_root = sys .argv [2 ]
13
12
14
- diff = unidiff .PatchSet .from_filename (sys .argv [1 ])
15
- for diff_file in diff :
13
+ # Create a set of all the files and the specific lines within that file that are in the diff
14
+ added_lines = set ()
15
+ for diff_file in unidiff .PatchSet .from_filename (sys .argv [1 ]):
16
16
filename = diff_file .target_file
17
17
# Skip files deleted in the tip (b side of the diff):
18
18
if filename == "/dev/null" :
25
25
if diff_line .line_type == "+" :
26
26
added_lines .add ((filename , diff_line .target_line_no ))
27
27
28
- for l in sys .stdin :
29
- bits = l .split (":" )
30
- if len (bits ) < 3 :
28
+ # Print the lines that are in the set
29
+ for line in sys .stdin :
30
+ line_parts = line .split (":" )
31
+ if len (line_parts ) < 3 :
31
32
continue
32
- filename = os .path .join (repository_root , bits [0 ])
33
- linenum = int (bits [1 ])
33
+ filename = os .path .join (repository_root , line_parts [0 ])
34
+ linenum = int (line_parts [1 ])
34
35
if (filename , linenum ) in added_lines :
35
- sys .stdout .write (l )
36
+ sys .stdout .write (line )
Original file line number Diff line number Diff line change 3
3
set -e
4
4
5
5
script_folder=` dirname $0 `
6
- absolute_repository_root=` readlink -f $script_folder /.. `
6
+ absolute_repository_root=` git rev-parse --show-toplevel `
7
7
8
8
if [[ " $# " -gt 2 ]]
9
9
then
20
20
exit 1
21
21
fi
22
22
23
+ if ! [[ -e $script_folder /filter_lint_by_diff.py ]]
24
+ then
25
+ echo " Lint filter script could not be found in the $script_folder directory"
26
+ echo " Ensure filter_lint_by_diff.py is inside the $script_folder directory then run again"
27
+ exit 1
28
+ fi
29
+
23
30
if [[ " $# " -gt 0 ]]
24
31
then
25
32
git_start=$1
@@ -62,7 +69,7 @@ for file in $diff_files; do
62
69
63
70
# Run the linting script and filter:
64
71
# The errors from the linter go to STDERR so must be redirected to STDOUT
65
- result=` $script_folder /cpplint.py $file 2>&1 | $script_folder /filter_lint_by_diff.py $diff_file $absolute_repository_root `
72
+ result=` $script_folder /cpplint.py $file 2>&1 > /dev/null | $script_folder /filter_lint_by_diff.py $diff_file $absolute_repository_root `
66
73
67
74
# Providing some errors were relevant we print them out
68
75
if [ " $result " ]
You can’t perform that action at this time.
0 commit comments