def _upload(self): # TODO Warn if there are local changes tmp_tar = git.create_archive(self.revision) try: core.put(tmp_tar, "deploy.tar.gz") core.run("tar -xzf deploy.tar.gz") file.remove("deploy.tar.gz") with ctx.unpatched_state(): file.write("VERSION", git.revparse(self.revision)) finally: core.local("rm -rf %s" % tmp_tar)
def _upload(owner, upload_dir, revision): tmp_tar = git.create_archive(revision) try: with ctx.cd(upload_dir): with ctx.sudo(): put(tmp_tar, 'deploy.tar.gz') file.attributes('deploy.tar.gz', owner=owner) with ctx.sudo(owner): run('tar -xzf deploy.tar.gz') file.remove('deploy.tar.gz') file.write('VERSION', git.revparse(revision)) finally: local('rm -rf %s' % tmp_tar)
def test_archive(temp_local, local): temp_local.expects_call().returns("/tmp") cmd = "git archive --format=tar foo | gzip > /tmp/repo.tar.gz" local.expects_call().with_args(cmd) assert git.create_archive("foo")