Beispiel #1
0
    def test_zip_append_archive(self):
        os.chdir(self.test_root)
        os.chdir('testDir')

        open('source_file.txt', 'w+').close()
        open('target_file.txt', 'w+').close()
        os.system('python -m zipfile -c source_file.zip source_file.txt')
        os.system('python -m zipfile -c target_file.zip target_file.txt')

        fileoperations.zip_append_archive('target_file.zip', 'source_file.zip')

        target_file_zip = zipfile.ZipFile('target_file.zip',
                                          'r',
                                          allowZip64=True)
        self.assertEqual(['source_file.txt', 'target_file.txt'],
                         sorted(target_file_zip.namelist()))
Beispiel #2
0
    def do_zip_submodule(self, main_location, sub_location, staged=False, submodule_dir=None):
        if staged:
            commit_id, stderr, exitcode = self._run_cmd(['git', 'write-tree'])

        else:
            commit_id = 'HEAD'

        io.log_info('creating zip using git submodule archive {0}'.format(commit_id))

        # individually zip submodules if there are any
        stdout, stderr, exitcode = self._run_cmd(['git', 'archive', '-v', '--format=zip',
                                                  '--prefix', os.path.join(submodule_dir, ''),
                                                  '-o', sub_location, commit_id])
        io.log_info('git archive output: {0}'.format(stderr))

        # append and remove the submodule archive
        fileoperations.zip_append_archive(main_location, sub_location)
        fileoperations.delete_file(sub_location)
    def do_zip_submodule(self, main_location, sub_location, staged=False, submodule_dir=None):
        if staged:
            commit_id, stderr, exitcode = self._run_cmd(['git', 'write-tree'])

        else:
            commit_id = 'HEAD'

        io.log_info('creating zip using git submodule archive {0}'.format(commit_id))

        # individually zip submodules if there are any
        stdout, stderr, exitcode = self._run_cmd(['git', 'archive', '-v', '--format=zip',
                                                  '--prefix', os.path.join(submodule_dir, ''),
                                                  '-o', sub_location, commit_id])
        io.log_info('git archive output: {0}'.format(stderr))

        # append and remove the submodule archive
        fileoperations.zip_append_archive(main_location, sub_location)
        fileoperations.delete_file(sub_location)