summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-02 16:56:07 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-02 17:38:55 +0900
commit75c0920744f874cd41797a1b1d2581bc30355a89 (patch)
treecea6719636308f561f3dc5035a034c60abeb1812
parent8b60c55e83af9204ebb784d7dfd30543576f4692 (diff)
downloadbuildstream-75c0920744f874cd41797a1b1d2581bc30355a89.tar.gz
plugins/sources/patch.py: Removing unneeded check
The patch plugin was checking if the target directory exists, however this is automatically guaranteed by the Source abstract class and documented to be guaranteed as well. Since this error cannot be caught by the plugin (it will be caught in advance by the Source class), removing the check from patch.py.
-rw-r--r--buildstream/plugins/sources/patch.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/buildstream/plugins/sources/patch.py b/buildstream/plugins/sources/patch.py
index 40fd106ec..a8a2da26c 100644
--- a/buildstream/plugins/sources/patch.py
+++ b/buildstream/plugins/sources/patch.py
@@ -80,14 +80,12 @@ class PatchSource(Source):
def stage(self, directory):
with self.timed_activity("Applying local patch: {}".format(self.path)):
- if not os.path.isdir(directory):
- raise SourceError(
- "Patch directory '{}' does not exist".format(directory),
- reason="patch-no-directory"
- )
- elif not os.listdir(directory):
- raise SourceError("Empty patch directory '{}'".format(directory),
+
+ # Bail out with a comprehensive message if the target directory is empty
+ if not os.listdir(directory):
+ raise SourceError("Nothing to patch in directory '{}'".format(directory),
reason="patch-no-files")
+
strip_level_option = "-p{}".format(self.strip_level)
self.call([self.host_patch, strip_level_option, "-i", self.fullpath, "-d", directory],
fail="Failed to apply patch {}".format(self.path))