From 16fb3829436584ceb08da3b05d88d7cc16cee6dc Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Thu, 20 Aug 2020 11:36:46 +0000 Subject: [PATCH] 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 --- ietf/checks.py | 9 +++++++++ ietf/utils/patch.py | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ietf/checks.py b/ietf/checks.py index 0316855ff..3499cdd27 100644 --- a/ietf/checks.py +++ b/ietf/checks.py @@ -319,6 +319,15 @@ def maybe_patch_library(app_configs, **kwargs): "\tTarget files: %s\n") % (library_path, ', '.join(force_str(i.target) for i in patch_set.items)), id="datatracker.W0002", )) + else: + # Patch succeeded or was a no-op + if not patch_set.already_patched: + errors.append( + checks.Error("Found an unpatched file, and applied the patch in %s" % (patch_file), + hint="You will need to re-run the command now that the patch in place.", + id="datatracker.E0022", + ) + ) else: errors.append(checks.Warning( "Could not parse patch file '%s'"%patch_file, diff --git a/ietf/utils/patch.py b/ietf/utils/patch.py index 03f7b9382..d14a34005 100644 --- a/ietf/utils/patch.py +++ b/ietf/utils/patch.py @@ -930,6 +930,7 @@ class PatchSet(object): if validhunks < len(p.hunks): if self._match_file_hunks(filename, p.hunks): warning("already patched %s" % filename) + self.already_patched = True else: warning("source file is different - %s" % filename) errors += 1 @@ -1175,9 +1176,9 @@ def main(): #pprint(patch) if options.revert: - patch.revert(options.strip, root=options.directory) or sys.exit(-1) + patch.revert(options.strip, root=options.directory.encode()) or sys.exit(-1) else: - patch.apply(options.strip, root=options.directory) or sys.exit(-1) + patch.apply(options.strip, root=options.directory.encode()) or sys.exit(-1) # todo: document and test line ends handling logic - patch.py detects proper line-endings # for inserted hunks and issues a warning if patched file has incosistent line ends