kopia lustrzana https://github.com/jupyterhub/repo2docker
Use cwd switching to do git operations
Setting just --git-dir is not enough, you also need to set --work-dir. Just setting cwd is betterpull/6/head
rodzic
1d24fdb7c3
commit
70d7c68134
|
@ -83,7 +83,7 @@ class Builder(Application):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for line in execute_cmd(['git', '--git-dir', os.path.join(output_path, '.git'), 'reset', '--hard', ref]):
|
for line in execute_cmd(['git', 'reset', '--hard', ref], output_path):
|
||||||
self.log.info(line, extra=dict(phase='fetching'))
|
self.log.info(line, extra=dict(phase='fetching'))
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
self.log.error('Failed to check out ref %s', ref, extra=dict(phase='failed'))
|
self.log.error('Failed to check out ref %s', ref, extra=dict(phase='failed'))
|
||||||
|
|
|
@ -65,12 +65,12 @@ class S2IBuildPack(BuildPack):
|
||||||
'build',
|
'build',
|
||||||
'--exclude', '""',
|
'--exclude', '""',
|
||||||
'--ref', ref,
|
'--ref', ref,
|
||||||
workdir,
|
'.',
|
||||||
build_image,
|
build_image,
|
||||||
output_image_spec,
|
output_image_spec,
|
||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
for line in execute_cmd(cmd):
|
for line in execute_cmd(cmd, cwd=workdir):
|
||||||
self.log.info(line, extra=dict(phase='building', builder=self.name))
|
self.log.info(line, extra=dict(phase='building', builder=self.name))
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
self.log.error('Failed to build image!', extra=dict(phase='failed'))
|
self.log.error('Failed to build image!', extra=dict(phase='failed'))
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def execute_cmd(cmd):
|
def execute_cmd(cmd, cwd=None):
|
||||||
"""
|
"""
|
||||||
Call given command, yielding output line by line
|
Call given command, yielding output line by line
|
||||||
"""
|
"""
|
||||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, cwd=cwd)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for line in iter(proc.stdout.readline, ''):
|
for line in iter(proc.stdout.readline, ''):
|
||||||
|
|
Ładowanie…
Reference in New Issue