Commit 0b8512cd authored by Michal Čihař's avatar Michal Čihař

Add option to specify multiple files to add to commit.

Issue #840
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent a4336479
......@@ -212,9 +212,11 @@ Post-add script
One of scripts defined in :setting:`POST_ADD_SCRIPTS` which is executed
when new translation has been added. This can be used to adjust additional
files in the repository when adding new translation.
Additional commit file
Additional file to include in commit, usually this one is generated by pre
commit script described above.
Additional commit files
Additional files to include in the commit (separated by newline), usually
this one is generated by the pre commit or post add scripts described
above.
Supply the ``%(language)s`` in the path like this:
``path/to/addditinal/%(language)s_file.example``
Save translation history
......
......@@ -35,6 +35,7 @@ Released on ? 2015.
* Add management command to change site name.
* Add option to confiugure default committer.
* Add hook after adding new translation.
* Add option to specify multiple files to add to commit.
weblate 2.3
-----------
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import weblate.trans.validators
class Migration(migrations.Migration):
dependencies = [
('trans', '0042_auto_20150910_0854'),
]
operations = [
migrations.AlterField(
model_name='subproject',
name='extra_commit_file',
field=models.TextField(default=b'', help_text='Additional files to include in commits, one per line; please check documentation for more details.', blank=True, verbose_name='Additional commit files', validators=[weblate.trans.validators.validate_extra_file]),
),
]
......@@ -214,15 +214,14 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
'and is slightly slower.'
),
)
extra_commit_file = models.CharField(
verbose_name=ugettext_lazy('Additional commit file'),
max_length=200,
extra_commit_file = models.TextField(
verbose_name=ugettext_lazy('Additional commit files'),
default='',
blank=True,
validators=[validate_extra_file],
help_text=ugettext_lazy(
'Additional file to include in commits; please check '
'documentation for more details.',
'Additional files to include in commits, one per line; '
'please check documentation for more details.',
)
)
post_update_script = models.CharField(
......@@ -1341,7 +1340,10 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
# Remove leading ./ from paths
self.filemask = cleanup_path(self.filemask)
self.template = cleanup_path(self.template)
self.extra_commit_file = cleanup_path(self.extra_commit_file)
extra_files = [
cleanup_path(x.strip()) for x in self.extra_commit_file.split('\n')
]
self.extra_commit_file = '\n'.join(filter(bool, extra_files))
# Save/Create object
super(SubProject, self).save(*args, **kwargs)
......
......@@ -753,16 +753,17 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
# Create list of files to commit
files = [self.filename]
if self.subproject.extra_commit_file != '':
extra_file = self.subproject.extra_commit_file % {
if self.subproject.extra_commit_file:
extra_files = self.subproject.extra_commit_file % {
'language': self.language_code,
}
full_path_extra = os.path.join(
self.subproject.get_path(),
extra_file
)
if os.path.exists(full_path_extra):
files.append(extra_file)
for extra_file in extra_files.split('\n'):
full_path_extra = os.path.join(
self.subproject.get_path(),
extra_file
)
if os.path.exists(full_path_extra):
files.append(extra_file)
# Do actual commit
self.repository.commit(
......
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