Example #1
0
    def test_clone(self):
        testdir = tempfile.mkdtemp()
        if self.acl:
            self.component.project.add_user(self.user, '@VCS')
        try:
            url = get_export_url(self.component).replace(
                'http://example.com', self.live_server_url
            ).replace(
                'http://', 'http://{0}:{1}@'.format(
                    self.user.username, self.user.auth_token.key
                )
            )
            process = subprocess.Popen(
                ['git', 'clone', url],
                cwd=testdir,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                stdin=subprocess.PIPE,
            )
            output = process.communicate()[0]
            retcode = process.poll()
        finally:
            shutil.rmtree(testdir)

        check = self.assertEqual if self.acl else self.assertNotEqual
        check(retcode, 0, 'Failed: {0}'.format(output))
Example #2
0
    def test_clone(self):
        testdir = tempfile.mkdtemp()
        if self.acl:
            self.component.project.add_user(self.user, '@VCS')
        try:
            url = (get_export_url(self.component).replace(
                'http://example.com', self.live_server_url).replace(
                    'http://',
                    'http://{0}:{1}@'.format(self.user.username,
                                             self.user.auth_token.key),
                ))
            process = subprocess.Popen(
                ['git', 'clone', url],
                cwd=testdir,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                stdin=subprocess.PIPE,
            )
            output = process.communicate()[0]
            retcode = process.poll()
        finally:
            shutil.rmtree(testdir)

        check = self.assertEqual if self.acl else self.assertNotEqual
        check(retcode, 0, 'Failed: {0}'.format(output))
Example #3
0
    def test_clone(self):
        testdir = tempfile.mkdtemp()
        if self.acl:
            self.component.project.add_user(self.user, "@VCS")
        try:
            url = (
                get_export_url(self.component)
                .replace("http://example.com", self.live_server_url)
                .replace(
                    "http://",
                    f"http://{self.user.username}:{self.user.auth_token.key}@",
                )
            )
            process = subprocess.Popen(
                ["git", "clone", url],
                cwd=testdir,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                stdin=subprocess.PIPE,
            )
            output = process.communicate()[0]
            retcode = process.poll()
        finally:
            remove_tree(testdir)

        check = self.assertEqual if self.acl else self.assertNotEqual
        check(retcode, 0, f"Failed: {output}")
Example #4
0
def set_export_url(apps, schema_editor):
    Component = apps.get_model('trans', 'Component')
    matching = Component.objects.filter(vcs__in=SUPPORTED_VCS).exclude(
        repo__startswith='weblate:/')
    for component in matching:
        new_url = get_export_url(component)
        if component.git_export != new_url:
            component.git_export = new_url
            component.save()
def set_export_url(apps, schema_editor):
    Component = apps.get_model("trans", "Component")
    db_alias = schema_editor.connection.alias
    matching = (Component.objects.using(db_alias).filter(
        vcs__in=SUPPORTED_VCS).exclude(repo__startswith="weblate:/"))
    for component in matching:
        new_url = get_export_url(component)
        if component.git_export != new_url:
            component.git_export = new_url
            component.save()
def set_export_url(apps, schema_editor):
    Component = apps.get_model('trans', 'Component')
    matching = Component.objects.filter(
        vcs__in=SUPPORTED_VCS
    ).exclude(
        repo__startswith='weblate:/'
    )
    for component in matching:
        new_url = get_export_url(component)
        if component.git_export != new_url:
            component.git_export = new_url
            component.save()
Example #7
0
 def test_get_export_url(self):
     self.assertEqual("http://example.com/git/test/test/",
                      get_export_url(self.component))
Example #8
0
 def test_get_export_url(self):
     self.assertEqual('http://example.com/git/test/test/',
                      get_export_url(self.subproject))
Example #9
0
 def test_get_export_url(self):
     self.assertEqual("http://example.com/git/test/test/", get_export_url(self.subproject))
Example #10
0
 def test_get_export_url(self):
     self.assertEqual(
         'http://example.com/git/test/test/',
         get_export_url(self.component)
     )