Skip to content

Commit 16fb382

Browse files
committed
Made the patch utility return information to distinguish already patched files from successful patch application, and modified our checks extensions to signal when patches have been applied and a ccommand needs to be re-run.
- Legacy-Id: 18386
1 parent bc75565 commit 16fb382

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

ietf/checks.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,15 @@ def maybe_patch_library(app_configs, **kwargs):
319319
"\tTarget files: %s\n") % (library_path, ', '.join(force_str(i.target) for i in patch_set.items)),
320320
id="datatracker.W0002",
321321
))
322+
else:
323+
# Patch succeeded or was a no-op
324+
if not patch_set.already_patched:
325+
errors.append(
326+
checks.Error("Found an unpatched file, and applied the patch in %s" % (patch_file),
327+
hint="You will need to re-run the command now that the patch in place.",
328+
id="datatracker.E0022",
329+
)
330+
)
322331
else:
323332
errors.append(checks.Warning(
324333
"Could not parse patch file '%s'"%patch_file,

ietf/utils/patch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ def apply(self, strip=0, root=None):
930930
if validhunks < len(p.hunks):
931931
if self._match_file_hunks(filename, p.hunks):
932932
warning("already patched %s" % filename)
933+
self.already_patched = True
933934
else:
934935
warning("source file is different - %s" % filename)
935936
errors += 1
@@ -1175,9 +1176,9 @@ def main():
11751176

11761177
#pprint(patch)
11771178
if options.revert:
1178-
patch.revert(options.strip, root=options.directory) or sys.exit(-1)
1179+
patch.revert(options.strip, root=options.directory.encode()) or sys.exit(-1)
11791180
else:
1180-
patch.apply(options.strip, root=options.directory) or sys.exit(-1)
1181+
patch.apply(options.strip, root=options.directory.encode()) or sys.exit(-1)
11811182

11821183
# todo: document and test line ends handling logic - patch.py detects proper line-endings
11831184
# for inserted hunks and issues a warning if patched file has incosistent line ends

0 commit comments

Comments
 (0)