Commit b2257087 authored by Michal Čihař's avatar Michal Čihař

Retry git commit as there might be other processes accessing repository in same time

parent d797844a
...@@ -10,6 +10,8 @@ from django.core.mail import mail_admins ...@@ -10,6 +10,8 @@ from django.core.mail import mail_admins
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from glob import glob from glob import glob
import os import os
import time
import random
import os.path import os.path
import logging import logging
import git import git
...@@ -351,6 +353,16 @@ class Translation(models.Model): ...@@ -351,6 +353,16 @@ class Translation(models.Model):
# No changes to commit # No changes to commit
return False return False
logger.info('Commiting %s as %s', self.filename, author) logger.info('Commiting %s as %s', self.filename, author)
try:
gitrepo.git.commit(
self.filename,
author = author,
m = settings.COMMIT_MESSAGE
)
except git.GitCommandError:
# There might be another attempt on commit in same time
# so we will sleep a bit an retry
time.sleep(random.random() * 2)
gitrepo.git.commit( gitrepo.git.commit(
self.filename, self.filename,
author = author, author = author,
......
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