|
1 | 1 | import os |
2 | 2 | import subprocess |
3 | | -import tempfile |
4 | 3 | from shutil import which |
5 | 4 |
|
6 | 5 | from vcs2l.clients.vcs_base import VcsClientBase |
@@ -789,40 +788,17 @@ def export_repository(self, version, basepath): |
789 | 788 | return False |
790 | 789 |
|
791 | 790 | self._check_executable() |
792 | | - filepath = '{0}.tar.gz'.format(basepath) |
793 | | - |
794 | | - # If current version matches export version and no local changes, export directly |
795 | | - current_sha = self._get_current_version() |
796 | | - export_sha = self._get_version_sha(version) if version else current_sha |
797 | | - if current_sha == export_sha and self._has_no_local_changes(): |
798 | | - cmd = [ |
799 | | - GitClient._executable, |
800 | | - 'archive', |
801 | | - '--format=tar.gz', |
802 | | - '--output={}'.format(filepath), |
803 | | - version or 'HEAD', |
804 | | - ] |
805 | | - result = self._run_command(cmd) |
806 | | - if result['returncode'] == 0: |
807 | | - return filepath |
808 | | - |
809 | | - # Otherwise use temp directory approach |
810 | | - tmpd_path = tempfile.mkdtemp() |
811 | | - try: |
812 | | - tmpgit = GitClient(tmpd_path) |
813 | | - if tmpgit.checkout(self.path, version=version, shallow=False): |
814 | | - cmd = [ |
815 | | - GitClient._executable, |
816 | | - 'archive', |
817 | | - '--format=tar.gz', |
818 | | - '--output={}'.format(filepath), |
819 | | - version or 'HEAD', |
820 | | - ] |
821 | | - result = tmpgit._run_command(cmd) |
822 | | - return filepath if result['returncode'] == 0 else False |
823 | | - return False |
824 | | - finally: |
825 | | - rmtree(tmpd_path) |
| 791 | + filepath = f'{basepath}.tar.gz' |
| 792 | + |
| 793 | + cmd = [ |
| 794 | + GitClient._executable, |
| 795 | + 'archive', |
| 796 | + '--format=tar.gz', |
| 797 | + f'--output={filepath}', |
| 798 | + version or 'HEAD', |
| 799 | + ] |
| 800 | + result = self._run_command(cmd) |
| 801 | + return filepath if result['returncode'] == 0 else False |
826 | 802 |
|
827 | 803 | def checkout(self, url, version=None, verbose=False, shallow=False, timeout=None): |
828 | 804 | """Clone a git repository to the specified path and checkout a specific version.""" |
|
0 commit comments