Update sync_new_code before archiving
@@ -76,8 +76,6 @@ class DownloadFilesView(ProjectResourceListEndpoint, ProtectedView):
self._object = get_object_or_404(Repo, project=self.project)
elif self.project.has_external_repo:
self._object = get_object_or_404(ExternalRepo, project=self.project)
- # Always fetch before downloading
- git.fetch(git_url=self._object.git_clone_url, repo_path=self._object.path)
else:
raise Http404('Repo was not found')
if not is_authenticated_internal_user(self.request.user):
@@ -88,8 +86,14 @@ class DownloadFilesView(ProjectResourceListEndpoint, ProtectedView):
external=False)
return self._object
+ def sync_new_code(self, repo):
+ if isinstance(repo, ExternalRepo):
+ # Always fetch before downloading
+ git.fetch(git_url=self._object.git_clone_url, repo_path=self._object.path)
+
def get(self, request, *args, **kwargs):
repo = self.get_object()
+ self.sync_new_code(repo=repo)
commit = self.request.query_params.get('commit', None)
archived_path, archive_name = archive_repo(repo_git=repo.git,
repo_name=self.project.name,
