Commit 567fa230 authored by Michal Čihař's avatar Michal Čihař

Do not hide failure from repository update

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 99e1eeab
......@@ -594,6 +594,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
self.log_info('update took %.2f seconds:', timediff)
for line in self.repository.last_output.splitlines():
self.log_debug('update: %s', line)
return True
except RepositoryException as error:
error_text = str(error)
self.log_error('failed to update repository: %s', error_text)
......@@ -606,6 +607,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
raise ValidationError(
_('Failed to fetch repository: %s') % error_text
)
return False
def configure_repo(self, validate=False):
'''
......@@ -640,7 +642,8 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
return self.linked_subproject.do_update(request)
# pull remote
self.update_remote_branch()
if not self.update_remote_branch():
return False
# do we have something to merge?
if not self.repo_needs_merge() and method != 'rebase':
......
......@@ -24,6 +24,8 @@ from weblate.trans.models import SubProject
from weblate.trans.tests.test_models import REPOWEB_URL
from weblate.trans.tests.test_views import ViewTestCase
from django.utils import timezone
import shutil
import os
EXTRA_PO = '''
#: accounts/models.py:319 trans/views/basic.py:104 weblate/html/index.html:21
......@@ -128,6 +130,17 @@ class MultiRepoTest(ViewTestCase):
)
self.assertEqual(translation.translated, 1)
def test_failed_update(self):
"""Test failed remote update."""
if os.path.exists(self.git_repo_path):
shutil.rmtree(self.git_repo_path)
if os.path.exists(self.hg_repo_path):
shutil.rmtree(self.hg_repo_path)
translation = self.subproject.translation_set.get(
language_code='cs'
)
self.assertFalse(translation.do_update(self.request))
def test_update(self):
'''
Tests handling update in case remote has changed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment