Commit 3d4af2cb authored by Stefano Rivera's avatar Stefano Rivera

Allow mass importing against an existing sub-project

parent e3a4df2a
......@@ -20,6 +20,7 @@
from django.core.management.base import BaseCommand, CommandError
from weblate.trans.models import SubProject, Project
from weblate.trans.util import is_repo_link
from glob import glob
import tempfile
import git
......@@ -118,8 +119,20 @@ class Command(BaseCommand):
'for subproject part of the match!'
)
names, sharedrepo = self.import_initial(project, repo, branch,
filemask)
if is_repo_link(repo):
sharedrepo = repo
master_sub_project = repo.rsplit('/', 1)[-1]
try:
sub_project = SubProject.objects.get(project=project,
slug=master_sub_project)
except SubProject.DoesNotExist:
raise CommandError('SubProject %s does not exist, '
'you need to create it first!' % repo)
names = self.get_matching_subprojects(sub_project.get_path(),
filemask)
else:
names, sharedrepo = self.import_initial(project, repo, branch,
filemask)
# Create remaining subprojects sharing git repository
for name in names:
......
......@@ -40,6 +40,23 @@ class ImportTest(RepoTestCase):
# We should have loaded two subprojects
self.assertEqual(project.subproject_set.count(), 2)
def test_import_against_existing(self):
'''
Test importing with a weblate:// URL
'''
android = self.create_android()
project = android.project
self.assertEqual(project.subproject_set.count(), 1)
call_command(
'import_project',
project.slug,
'weblate://%s/%s' % (project.slug, android.slug),
'master',
'**/*.po',
)
# We should have loaded two subprojects
self.assertEqual(project.subproject_set.count(), 3)
def test_import_missing_project(self):
'''
Test of correct handling of missing project.
......
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