def setUp(self): # Path where to clone remote repo for tests self.git_base_repo_path = os.path.join( settings.DATA_DIR, 'test-base-repo.git' ) # Repository on which tests will be performed self.git_repo_path = os.path.join( settings.DATA_DIR, 'test-repo.git' ) # Path where to clone remote repo for tests self.hg_base_repo_path = os.path.join( settings.DATA_DIR, 'test-base-repo.hg' ) # Repository on which tests will be performed self.hg_repo_path = os.path.join( settings.DATA_DIR, 'test-repo.hg' ) # Clone repo for testing if not os.path.exists(self.git_base_repo_path): GitRepository.clone( GIT_URL, self.git_base_repo_path, bare=True ) # Remove possibly existing directory if os.path.exists(self.git_repo_path): shutil.rmtree(self.git_repo_path) # Create repository copy for the test shutil.copytree(self.git_base_repo_path, self.git_repo_path) # Clone repo for testing if not os.path.exists(self.hg_base_repo_path): HgRepository.clone( HG_URL, self.hg_base_repo_path, bare=True ) # Remove possibly existing directory if os.path.exists(self.hg_repo_path): shutil.rmtree(self.hg_repo_path) # Create repository copy for the test shutil.copytree(self.hg_base_repo_path, self.hg_repo_path) # Remove possibly existing project directory test_repo_path = os.path.join(settings.DATA_DIR, 'vcs', 'test') if os.path.exists(test_repo_path): shutil.rmtree(test_repo_path)
def ready(self): # Configure merge driver for Gettext PO try: GitRepository.global_setup() except RepositoryException as error: add_configuration_error("Git global setup", "Failed to do git setup: {0}".format(error)) # Use it for *.po by default configdir = os.path.join(data_dir("home"), ".config", "git") configfile = os.path.join(configdir, "attributes") if not os.path.exists(configfile): if not os.path.exists(configdir): os.makedirs(configdir) with open(configfile, "w") as handle: handle.write("*.po merge=weblate-merge-gettext-po\n")
def setUp(self): # Path where to clone remote repo for tests self.git_base_repo_path = os.path.join(settings.DATA_DIR, 'test-base-repo.git') # Repository on which tests will be performed self.git_repo_path = os.path.join(settings.DATA_DIR, 'test-repo.git') # Path where to clone remote repo for tests self.hg_base_repo_path = os.path.join(settings.DATA_DIR, 'test-base-repo.hg') # Repository on which tests will be performed self.hg_repo_path = os.path.join(settings.DATA_DIR, 'test-repo.hg') # Clone repo for testing if not os.path.exists(self.git_base_repo_path): print('Cloning Git test repository to {0}...'.format( self.git_base_repo_path)) GitRepository.clone(GIT_URL, self.git_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.git_repo_path): shutil.rmtree(self.git_repo_path) # Create repository copy for the test shutil.copytree(self.git_base_repo_path, self.git_repo_path) if HgRepository.is_supported(): # Clone repo for testing if not os.path.exists(self.hg_base_repo_path): print('Cloning Mercurial test repository to {0}...'.format( self.hg_base_repo_path)) HgRepository.clone(HG_URL, self.hg_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.hg_repo_path): shutil.rmtree(self.hg_repo_path) # Create repository copy for the test shutil.copytree(self.hg_base_repo_path, self.hg_repo_path) # Remove possibly existing project directory test_repo_path = os.path.join(settings.DATA_DIR, 'vcs', 'test') if os.path.exists(test_repo_path): shutil.rmtree(test_repo_path) # Remove indexes clean_indexes()
def ready(self): # Configure merge driver for Gettext PO try: GitRepository.global_setup() except RepositoryException as error: add_configuration_error( 'Git global setup', 'Failed to do git setup: {0}'.format(error)) # Use it for *.po by default configdir = os.path.join(data_dir('home'), '.config', 'git') configfile = os.path.join(configdir, 'attributes') if not os.path.exists(configfile): if not os.path.exists(configdir): os.makedirs(configdir) with open(configfile, 'w') as handle: handle.write('*.po merge=weblate-merge-gettext-po\n')
def ready(self): # Configure merge driver for Gettext PO try: GitRepository.global_setup() except RepositoryException as error: add_configuration_error( 'Git global setup', 'Failed to do git setup: {0}'.format(error) ) # Use it for *.po by default configdir = os.path.join(data_dir('home'), '.config', 'git') configfile = os.path.join(configdir, 'attributes') if not os.path.exists(configfile): if not os.path.exists(configdir): os.makedirs(configdir) with open(configfile, 'w') as handle: handle.write('*.po merge=weblate-merge-gettext-po\n')
def setUp(self): if 'test-repos' in settings.GIT_ROOT: test_dir = os.path.join(settings.GIT_ROOT, 'test') if os.path.exists(test_dir): shutil.rmtree(test_dir) # Path where to clone remote repo for tests self.git_base_repo_path = os.path.join(settings.GIT_ROOT, 'test-base-repo.git') # Repository on which tests will be performed self.git_repo_path = os.path.join(settings.GIT_ROOT, 'test-repo.git') # Path where to clone remote repo for tests self.hg_base_repo_path = os.path.join(settings.GIT_ROOT, 'test-base-repo.hg') # Repository on which tests will be performed self.hg_repo_path = os.path.join(settings.GIT_ROOT, 'test-repo.hg') # Clone repo for testing if not os.path.exists(self.git_base_repo_path): GitRepository.clone(GIT_URL, self.git_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.git_repo_path): shutil.rmtree(self.git_repo_path) # Create repository copy for the test shutil.copytree(self.git_base_repo_path, self.git_repo_path) # Clone repo for testing if not os.path.exists(self.hg_base_repo_path): HgRepository.clone(HG_URL, self.hg_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.hg_repo_path): shutil.rmtree(self.hg_repo_path) # Create repository copy for the test shutil.copytree(self.hg_base_repo_path, self.hg_repo_path) # Remove possibly existing project directory test_repo_path = os.path.join(settings.GIT_ROOT, 'test') if os.path.exists(test_repo_path): shutil.rmtree(test_repo_path)
def setUp(self): # Path where to clone remote repo for tests self.git_base_repo_path = os.path.join(settings.DATA_DIR, "test-base-repo.git") # Repository on which tests will be performed self.git_repo_path = os.path.join(settings.DATA_DIR, "test-repo.git") # Path where to clone remote repo for tests self.hg_base_repo_path = os.path.join(settings.DATA_DIR, "test-base-repo.hg") # Repository on which tests will be performed self.hg_repo_path = os.path.join(settings.DATA_DIR, "test-repo.hg") # Clone repo for testing if not os.path.exists(self.git_base_repo_path): print("Cloning Git test repository to {0}...".format(self.git_base_repo_path)) GitRepository.clone(GIT_URL, self.git_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.git_repo_path): shutil.rmtree(self.git_repo_path) # Create repository copy for the test shutil.copytree(self.git_base_repo_path, self.git_repo_path) # Clone repo for testing if not os.path.exists(self.hg_base_repo_path): print("Cloning Mercurial test repository to {0}...".format(self.hg_base_repo_path)) HgRepository.clone(HG_URL, self.hg_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.hg_repo_path): shutil.rmtree(self.hg_repo_path) # Create repository copy for the test shutil.copytree(self.hg_base_repo_path, self.hg_repo_path) # Remove possibly existing project directory test_repo_path = os.path.join(settings.DATA_DIR, "vcs", "test") if os.path.exists(test_repo_path): shutil.rmtree(test_repo_path) # Remove indexes clean_indexes()
def checkout_tmp(self, project, repo, branch): ''' Checkouts project to temporary location. ''' # Create temporary working dir workdir = tempfile.mkdtemp(dir=project.get_path()) os.chmod(workdir, 0o755) # Initialize git repository self.logger.info('Cloning git repository...') gitrepo = GitRepository.clone(repo, workdir) self.logger.info('Updating working copy in git repository...') gitrepo.configure_branch(branch) return workdir
def setUp(self): if 'test-repos' in settings.GIT_ROOT: test_dir = os.path.join(settings.GIT_ROOT, 'test') if os.path.exists(test_dir): shutil.rmtree(test_dir) # Path where to clone remote repo for tests self.base_repo_path = os.path.join( settings.GIT_ROOT, 'test-base-repo.git' ) # Repository on which tests will be performed self.repo_path = os.path.join( settings.GIT_ROOT, 'test-repo.git' ) # Clone repo for testing if not os.path.exists(self.base_repo_path): GitRepository.clone( GIT_URL, self.base_repo_path, bare=True ) # Remove possibly existing directory if os.path.exists(self.repo_path): shutil.rmtree(self.repo_path) # Create repository copy for the test shutil.copytree(self.base_repo_path, self.repo_path) # Remove possibly existing project directory test_repo_path = os.path.join(settings.GIT_ROOT, 'test') if os.path.exists(test_repo_path): shutil.rmtree(test_repo_path)
def test_revision(self): repo = GitRepository.clone(self.repo_path, self._tempdir) self.assertEquals(repo.last_revision, repo.last_remote_revision)
def test_status(self): repo = GitRepository.clone(self.repo_path, self._tempdir) status = repo.status() self.assertTrue( "Your branch is up-to-date with 'origin/master'." in status )
def test_clone(self): GitRepository.clone(self.repo_path, self._tempdir)
def get_versions(): """ Returns list of used versions. """ result = [] result.append(("Python", "http://www.python.org/", sys.version.split()[0], "2.7")) name = "Django" url = "https://www.djangoproject.com/" mod = get_version_module("django", name, url) result.append((name, url, mod.get_version(), "1.7")) name = "six" url = "https://pypi.python.org/pypi/six" mod = get_version_module("six", name, url) result.append((name, url, mod.__version__, "1.7.0")) name = "python-social-auth" url = "http://psa.matiasaguirre.net/" mod = get_version_module("social", name, url) result.append((name, url, mod.__version__, "0.2.0")) name = "Translate Toolkit" url = "http://toolkit.translatehouse.org/" mod = get_version_module("translate.__version__", name, url) result.append((name, url, mod.sver, "1.10.0")) name = "Whoosh" url = "http://bitbucket.org/mchaput/whoosh/" mod = get_version_module("whoosh", name, url) result.append((name, url, mod.versionstring(), "2.5")) try: result.append(("Git", "http://git-scm.com/", GitRepository.get_version(), "1.6")) except OSError: raise Exception("Failed to run git, please install it.") name = "Pillow (PIL)" url = "http://python-imaging.github.io/" mod = get_version_module("PIL.Image", name, url) result.append((name, url, mod.VERSION, "1.1.6")) name = "dateutil" url = "http://labix.org/python-dateutil" mod = get_version_module("dateutil", name, url) result.append((name, url, mod.__version__, "1.0")) name = "lxml" url = "http://lxml.de/" mod = get_version_module("lxml.etree", name, url) result.append((name, url, mod.__version__, "3.1.0")) name = "django-crispy-forms" url = "http://django-crispy-forms.readthedocs.org/" mod = get_version_module("crispy_forms", name, url) result.append((name, url, mod.__version__, "1.4.0")) name = "compressor" url = "https://github.com/django-compressor/django-compressor" mod = get_version_module("compressor", name, url) result.append((name, url, mod.__version__, "1.5")) return result
# Version string without suffix VERSION_BASE = VERSION # User-Agent string to use USER_AGENT = 'Weblate/{0}'.format(VERSION) # Are we running git RUNNING_GIT = is_running_git() GIT_RELEASE = False GIT_VERSION = VERSION # Grab some information from git if RUNNING_GIT: try: # Describe current checkout GIT_VERSION = GitRepository(get_root_dir()).describe() # Check if we're close to release tag parts = GIT_VERSION.split('-') GIT_RELEASE = (len(parts) <= 2 or int(parts[2]) < 20) del parts # Mark version as devel if it is if not GIT_RELEASE: VERSION += '-dev' except (RepositoryException, OSError): # Import failed or git has troubles reading # repo (eg. swallow clone) RUNNING_GIT = False
def test_needs_commit(self): repo = GitRepository.clone(self.repo_path, self._tempdir) self.assertFalse(repo.needs_commit())
def test_rebase(self): repo = GitRepository.clone(self.repo_path, self._tempdir) repo.rebase('master')
def get_versions(): ''' Returns list of used versions. ''' result = [] result.append(( 'Python', 'http://www.python.org/', sys.version.split()[0], '2.7', )) name = 'Django' url = 'https://www.djangoproject.com/' mod = get_version_module('django', name, url) result.append(( name, url, mod.get_version(), '1.6', )) name = 'python-social-auth' url = 'http://psa.matiasaguirre.net/' mod = get_version_module('social', name, url) result.append(( name, url, mod.__version__, '0.2.0', )) name = 'Translate Toolkit' url = 'http://toolkit.translatehouse.org/' mod = get_version_module('translate.__version__', name, url) result.append(( name, url, mod.sver, '1.9.0', )) name = 'Whoosh' url = 'http://bitbucket.org/mchaput/whoosh/' mod = get_version_module('whoosh', name, url) result.append(( name, url, mod.versionstring(), '2.5', )) try: result.append(( 'Git', 'http://git-scm.com/', GitRepository.get_version(), '1.6', )) except OSError: raise Exception('Failed to run git, please install it.') name = 'South' url = 'http://south.aeracode.org/' if django.VERSION < (1, 7, 0): mod = get_version_module('south', name, url) result.append(( name, url, mod.__version__, '1.0', )) name = 'Pillow (PIL)' url = 'http://python-imaging.github.io/' mod = get_version_module('PIL.Image', name, url) result.append(( name, url, mod.VERSION, '1.1.6', )) name = 'dateutil' url = 'http://labix.org/python-dateutil' mod = get_version_module('dateutil', name, url) result.append(( name, url, mod.__version__, '1.0' )) name = 'lxml' url = 'http://lxml.de/' mod = get_version_module('lxml.etree', name, url) result.append(( name, url, mod.__version__, '3.1.0', )) name = 'django-crispy-forms' url = 'http://django-crispy-forms.readthedocs.org/' mod = get_version_module('crispy_forms', name, url) result.append(( name, url, mod.__version__, '1.4.0', )) return result
def get_versions(): ''' Returns list of used versions. ''' result = [] result.append(( 'Python', 'http://www.python.org/', sys.version.split()[0], '2.7', )) name = 'Django' url = 'https://www.djangoproject.com/' mod = get_version_module('django', name, url) result.append(( name, url, mod.get_version(), '1.8', )) name = 'six' url = 'https://pypi.python.org/pypi/six' mod = get_version_module('six', name, url) result.append(( name, url, mod.__version__, '1.7.0', )) name = 'python-social-auth' url = 'http://psa.matiasaguirre.net/' mod = get_version_module('social', name, url) result.append(( name, url, mod.__version__, '0.2.0', )) name = 'Translate Toolkit' url = 'http://toolkit.translatehouse.org/' mod = get_version_module('translate.__version__', name, url) result.append(( name, url, mod.sver, '1.10.0', )) name = 'Whoosh' url = 'http://bitbucket.org/mchaput/whoosh/' mod = get_version_module('whoosh', name, url) result.append(( name, url, mod.versionstring(), '2.5', )) try: result.append(( 'Git', 'http://git-scm.com/', GitRepository.get_version(), '1.6', )) except OSError: raise Exception('Failed to run git, please install it.') name = 'Pillow (PIL)' url = 'http://python-imaging.github.io/' mod = get_version_module('PIL.Image', name, url) result.append(( name, url, mod.VERSION, '1.1.6', )) name = 'dateutil' url = 'http://labix.org/python-dateutil' mod = get_version_module('dateutil', name, url) result.append(( name, url, mod.__version__, '1.0' )) name = 'lxml' url = 'http://lxml.de/' mod = get_version_module('lxml.etree', name, url) result.append(( name, url, mod.__version__, '3.1.0', )) name = 'django-crispy-forms' url = 'http://django-crispy-forms.readthedocs.org/' mod = get_version_module('crispy_forms', name, url) result.append(( name, url, mod.__version__, '1.4.0', )) name = 'compressor' url = 'https://github.com/django-compressor/django-compressor' mod = get_version_module('compressor', name, url) result.append(( name, url, mod.__version__, '1.5', )) return result
# Version string without suffix VERSION_BASE = VERSION # User-Agent string to use USER_AGENT = "Weblate/{0}".format(VERSION) # Are we running git RUNNING_GIT = is_running_git() GIT_RELEASE = False GIT_VERSION = VERSION # Grab some information from git if RUNNING_GIT: try: # Describe current checkout GIT_VERSION = GitRepository(get_root_dir()).describe() # Check if we're close to release tag parts = GIT_VERSION.split("-") GIT_RELEASE = len(parts) <= 2 or int(parts[2]) < 20 del parts # Mark version as devel if it is if not GIT_RELEASE: VERSION += "-dev" except (RepositoryException, OSError): # Import failed or git has troubles reading # repo (eg. swallow clone) RUNNING_GIT = False
return os.path.abspath(os.path.join(curdir, '..')) # Weblate version VERSION = '2.20' # Version string without suffix VERSION_BASE = VERSION.replace('-dev', '') # User-Agent string to use USER_AGENT = 'Weblate/{0}'.format(VERSION) # Grab some information from git try: # Describe current checkout GIT_VERSION = GitRepository(get_root_dir(), local=True).describe() except (RepositoryException, OSError): # Import failed or git has troubles reading # repo (eg. swallow clone) GIT_VERSION = VERSION def get_doc_url(page, anchor=''): """Return URL to documentation.""" # Should we use tagged release or latest version if '-dev' in VERSION: version = 'latest' else: version = 'weblate-{0}'.format(VERSION) # Generate URL url = 'https://docs.weblate.org/en/{0}/{1}.html'.format(version, page)
def setUp(self): super(VCSGitTest, self).setUp() self._tempdir = tempfile.mkdtemp() self.repo = GitRepository.clone(self.repo_path, self._tempdir)
def test_get_version(self): self.assertTrue(GitRepository.get_version() != '')
def test_update_remote(self): repo = GitRepository.clone(self.repo_path, self._tempdir) repo.update_remote()
def test_push(self): repo = GitRepository.clone(self.repo_path, self._tempdir) repo.push('master')
def test_status(self): repo = GitRepository.clone(self.repo_path, self._tempdir) status = repo.status() self.assertTrue( "Your branch is up-to-date with 'origin/master'." in status)
def get_versions(): ''' Returns list of used versions. ''' result = [] result.append(( 'Python', 'http://www.python.org/', sys.version.split()[0], '2.7', )) result.append(get_single( 'Django', 'https://www.djangoproject.com/', 'django', '1.9', 'get_version' )) result.append(get_single( 'six', 'https://pypi.python.org/pypi/six', 'six', '1.7.0', )) result.append(get_single( 'python-social-auth', 'http://psa.matiasaguirre.net/', 'social', '0.2.0', )) result.append(get_single( 'Translate Toolkit', 'http://toolkit.translatehouse.org/', 'translate.__version__', '1.14.0-rc1', 'sver', )) result.append(get_single( 'Whoosh', 'http://bitbucket.org/mchaput/whoosh/', 'whoosh', '2.5', 'versionstring', )) result.append(get_single( 'defusedxml', 'https://bitbucket.org/tiran/defusedxml', 'defusedxml', '0.4', )) try: result.append(( 'Git', 'http://git-scm.com/', GitRepository.get_version(), '1.6', )) except OSError: raise Exception('Failed to run git, please install it.') result.append(get_single( 'Pillow (PIL)', 'http://python-imaging.github.io/', 'PIL.Image', '1.1.6', 'VERSION', )) result.append(get_single( 'dateutil', 'http://labix.org/python-dateutil', 'dateutil', '1.0' )) result.append(get_single( 'lxml', 'http://lxml.de/', 'lxml.etree', '3.1.0', )) result.append(get_single( 'django-crispy-forms', 'http://django-crispy-forms.readthedocs.org/', 'crispy_forms', '1.4.0', )) result.append(get_single( 'compressor', 'https://github.com/django-compressor/django-compressor', 'compressor', '1.5', )) result.append(get_single( 'djangorestframework', 'http://www.django-rest-framework.org/', 'rest_framework', '3.3', )) return result
def get_versions(): ''' Returns list of used versions. ''' result = [] result.append(( 'Python', 'http://www.python.org/', sys.version.split()[0], '2.7', )) result.append( get_single('Django', 'https://www.djangoproject.com/', 'django', '1.10', 'get_version')) result.append( get_single( 'six', 'https://pypi.python.org/pypi/six', 'six', '1.7.0', )) result.append( get_single( 'social-auth-core', 'http://python-social-auth.readthedocs.io/', 'social_core', '1.2.0', )) result.append( get_single( 'social-auth-app-django', 'http://python-social-auth.readthedocs.io/', 'social_django', '1.1.0', )) result.append( get_single('django-appconf', 'https://github.com/django-compressor/django-appconf', 'appconf', '1.0')) result.append( get_single( 'Translate Toolkit', 'http://toolkit.translatehouse.org/', 'translate.__version__', '2.0.0', 'sver', )) result.append( get_single( 'Whoosh', 'http://bitbucket.org/mchaput/whoosh/', 'whoosh', '2.7', 'versionstring', )) result.append( get_single( 'defusedxml', 'https://bitbucket.org/tiran/defusedxml', 'defusedxml', '0.4', )) try: result.append(( 'Git', 'https://git-scm.com/', GitRepository.get_version(), '1.6', )) except OSError: raise Exception('Failed to run git, please install it.') result.append( get_single( 'Pillow (PIL)', 'http://python-pillow.org/', 'PIL.Image', '1.1.6', 'VERSION', )) result.append( get_single('dateutil', 'http://labix.org/python-dateutil', 'dateutil', '1.0')) result.append( get_single( 'lxml', 'http://lxml.de/', 'lxml.etree', '3.1.0', )) result.append( get_single( 'django-crispy-forms', 'http://django-crispy-forms.readthedocs.io/', 'crispy_forms', '1.6.1', )) result.append( get_single( 'compressor', 'https://github.com/django-compressor/django-compressor', 'compressor', '2.1', )) result.append( get_single( 'djangorestframework', 'http://www.django-rest-framework.org/', 'rest_framework', '3.4', )) return result
def test_revision(self): repo = GitRepository.clone(self.repo_path, self._tempdir) self.assertEquals( repo.last_revision, repo.last_remote_revision )
return os.path.abspath(os.path.join(curdir, '..')) # Weblate version VERSION = '2.14' # Version string without suffix VERSION_BASE = VERSION.replace('-dev', '') # User-Agent string to use USER_AGENT = 'Weblate/{0}'.format(VERSION) # Grab some information from git try: # Describe current checkout GIT_VERSION = GitRepository(get_root_dir()).describe() except (RepositoryException, OSError): # Import failed or git has troubles reading # repo (eg. swallow clone) GIT_VERSION = VERSION def get_doc_url(page, anchor=''): """Return URL to documentation.""" # Should we use tagged release or latest version if '-dev' in VERSION: version = 'latest' else: version = 'weblate-{0}'.format(VERSION) # Generate URL url = 'https://docs.weblate.org/en/{0}/{1}.html'.format(version, page)