Add error checking for subdir
@@ -663,7 +663,13 @@ class Repo2Docker(Application):
if self.repo_type == 'remote':
self.fetch(self.repo, self.ref, checkout_path)
- os.chdir(os.path.join(checkout_path, self.subdir).rstrip('/'))
+ if self.subdir:
+ checkout_path = os.path.join(checkout_path, self.subdir).rstrip('/')
+ if not os.path.exists(checkout_path):
+ self.log.error('Subdirectory %s does not exist', self.subdir, extra=dict(phase='failure'))
+ sys.exit(1)
+
+ os.chdir(checkout_path)
for BP in self.buildpacks:
bp = BP()
