Properly support local directories

We don't need git!
pull/42/head
yuvipanda 2017-07-29 14:17:32 -07:00
rodzic 64bf17513f
commit 65c89e1f61
1 zmienionych plików z 24 dodań i 12 usunięć

Wyświetl plik

@ -145,7 +145,7 @@ class Repo2Docker(Application):
argparser.add_argument(
'repo',
help='Path to repository that should be built'
help='Path to repository that should be built. Could be local path or a git URL.'
)
argparser.add_argument(
@ -153,6 +153,11 @@ class Repo2Docker(Application):
help='Name of image to be built. If unspecified will be autogenerated'
)
argparser.add_argument(
'--ref',
help='If building a git url, which ref to check out'
)
argparser.add_argument(
'--push',
dest='push',
@ -180,11 +185,15 @@ class Repo2Docker(Application):
self.load_config_file(args.config)
if '@' in args.repo:
self.repo, self.ref = args.repo.split('@', 1)
else:
if os.path.exists(args.repo):
# Let's treat this as a local directory we are building
self.repo_type = 'local'
self.repo = args.repo
self.ref = None
else:
self.repo_type = 'remote'
self.repo = args.repo
self.ref = args.ref
if args.json_logs:
# Need to reset existing handlers, or we repeat messages
@ -207,7 +216,7 @@ class Repo2Docker(Application):
else:
# Attempt to set a sane default!
# HACK: Provide something more descriptive?
self.output_image_spec = 'image-' + escapism.escape(self.repo).lower()
self.output_image_spec = 'r2d' + escapism.escape(self.repo, escape_char='-').lower() + str(int(time.time()))
self.push = args.push
self.run = args.run
@ -278,12 +287,15 @@ class Repo2Docker(Application):
return port
def start(self):
checkout_path = os.path.join(self.git_workdir, str(uuid.uuid4()))
self.fetch(
self.repo,
self.ref,
checkout_path
)
if self.repo_type == 'local':
checkout_path = self.repo
else:
checkout_path = os.path.join(self.git_workdir, str(uuid.uuid4()))
self.fetch(
self.repo,
self.ref,
checkout_path
)
os.chdir(checkout_path)
for bp_spec in self.buildpacks:
@ -302,7 +314,7 @@ class Repo2Docker(Application):
else:
raise Exception("No builder found!")
if self.cleanup_checkout:
if self.repo_type != 'local' and self.cleanup_checkout:
shutil.rmtree(checkout_path)
if self.push: