Correctly handle situation when there are no updates
This commit is contained in:
parent
93d3f7e288
commit
0189235122
@ -291,12 +291,17 @@ class Translation(models.Model):
|
||||
Commits translation to git.
|
||||
'''
|
||||
repo = self.subproject.get_repo()
|
||||
status = repo.git.status('--porcelain', '--', self.filename)
|
||||
if status == '':
|
||||
# No changes to commit
|
||||
return False
|
||||
logger.info('Commiting %s as %s', self.filename, author)
|
||||
repo.git.commit(
|
||||
self.filename,
|
||||
author = author,
|
||||
m = settings.COMMIT_MESSAGE
|
||||
)
|
||||
return True
|
||||
|
||||
def update_unit(self, unit, request):
|
||||
'''
|
||||
@ -380,8 +385,9 @@ class Translation(models.Model):
|
||||
unit1.merge(unit2, overwrite=overwrite)
|
||||
store1.save()
|
||||
author = u'%s <%s>' % (request.user.get_full_name(), request.user.email)
|
||||
self.git_commit(author)
|
||||
ret = self.git_commit(author)
|
||||
self.check_sync()
|
||||
return ret
|
||||
|
||||
class Unit(models.Model):
|
||||
translation = models.ForeignKey(Translation)
|
||||
|
@ -181,8 +181,11 @@ def upload_translation(request, project, subproject, lang):
|
||||
form = UploadForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
try:
|
||||
obj.merge_upload(request, request.FILES['file'], form.cleaned_data['overwrite'])
|
||||
ret = obj.merge_upload(request, request.FILES['file'], form.cleaned_data['overwrite'])
|
||||
if ret:
|
||||
messages.add_message(request, messages.INFO, _('File content successfully merged into translation.'))
|
||||
else:
|
||||
messages.add_message(request, messages.INFO, _('There were no new strings in uploaded file.'))
|
||||
except Exception, e:
|
||||
messages.add_message(request, messages.ERROR, _('File content merge failed: %s' % str(e)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user