@@ -146,33 +146,27 @@ def run_kernel_doc(tree, commitish, files, logs) -> List[KdocWarning]:
146146
147147 return parse_warnings (lines , logs )
148148
149- def extract_files (patch ):
150- """Extract paths added or modified by the patch ."""
149+ def extract_files (tree ):
150+ """Extract paths added or modified by the commit ."""
151151
152- before_files = set ()
153- after_files = set ()
154- lines = patch .raw_patch .split ("\n " )
152+ # Get files that existed before (modified or deleted)
153+ cmd = ["git" , "diff" , "--name-only" , "--diff-filter=MD" , "HEAD~.." ]
154+ result = subprocess .run (cmd , cwd = tree .path , capture_output = True ,
155+ text = True , check = True )
156+ before_files = [f for f in result .stdout .strip ().split ('\n ' ) if f ]
155157
156- # Walk lines, skip last since it doesn't have next
157- for i , line in enumerate (lines [:- 1 ]):
158- next_line = lines [i + 1 ]
158+ # Get files that exist after (added or modified)
159+ cmd = ["git" , "diff" , "--name-only" , "--diff-filter=AM" , "HEAD~.." ]
160+ result = subprocess .run (cmd , cwd = tree .path , capture_output = True ,
161+ text = True , check = True )
162+ after_files = [f for f in result .stdout .strip ().split ('\n ' ) if f ]
159163
160- if not next_line .startswith ("+++ b/" ):
161- continue
162-
163- file_path = next_line [6 :]
164-
165- if "/dev/null" not in line :
166- before_files .add (file_path )
167- if "/dev/null" not in next_line :
168- after_files .add (file_path )
169-
170- return list (before_files ), list (after_files )
164+ return before_files , after_files
171165
172- def kdoc (tree , patch , _result_dir ) -> Tuple [int , str , str ]:
166+ def kdoc (tree , _patch , _result_dir ) -> Tuple [int , str , str ]:
173167 """ Main function / entry point """
174168
175- before_files , after_files = extract_files (patch )
169+ before_files , after_files = extract_files (tree )
176170
177171 if not before_files and not after_files :
178172 return 1 , "Patch has no modified files?" , ""
0 commit comments