Commit 8b57ae69 authored by Michal Čihař's avatar Michal Čihař

Factor out check for need of commit

parent 78b2ba78
......@@ -406,15 +406,25 @@ class Translation(models.Model):
m = settings.COMMIT_MESSAGE
)
def git_commit(self, author, force_commit = False):
def git_needs_commit(self, gitrepo = None):
'''
Wrapper for commiting translation to git.
Checks whether there are some not commited changes.
'''
gitrepo = self.subproject.get_repo()
if gitrepo is None:
gitrepo = self.subproject.get_repo()
status = gitrepo.git.status('--porcelain', '--', self.filename)
if status == '':
# No changes to commit
return False
return True
def git_commit(self, author, force_commit = False):
'''
Wrapper for commiting translation to git.
'''
gitrepo = self.subproject.get_repo()
if not self.git_needs_commit(gitrepo)
return False
if not force_commit and settings.LAZY_COMMITS:
logger.info('Delaying commiting %s as %s', self.filename, author)
return False
......
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