Changeset - 84414d73c233
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 13 years ago 2012-10-02 21:32:00
marcin@python-works.com
Add git version detection to warn users that Git used in system is to old. ref #588
- also show git version in system details in settings page
3 files changed with 42 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/environment.py
Show inline comments
 
@@ -15,13 +15,13 @@ import rhodecode.lib.app_globals as app_
 

	
 
from rhodecode.config.routing import make_map
 

	
 
from rhodecode.lib import helpers
 
from rhodecode.lib.auth import set_available_permissions
 
from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config,\
 
    load_rcextensions
 
    load_rcextensions, check_git_version
 
from rhodecode.lib.utils2 import engine_from_config, str2bool
 
from rhodecode.model import init_model
 
from rhodecode.model.scm import ScmModel
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -83,12 +83,15 @@ def load_environment(global_conf, app_co
 
        if not int(os.environ.get('RC_NO_TMP_PATH', 0)):
 
            create_test_env(TESTS_TMP_PATH, config)
 
        # set RC_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests
 
        if not int(os.environ.get('RC_WHOOSH_TEST_DISABLE', 0)):
 
            create_test_index(TESTS_TMP_PATH, config, True)
 

	
 
    #check git version
 
    check_git_version()
 

	
 
    # MULTIPLE DB configs
 
    # Setup the SQLAlchemy database engine
 
    sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
 
    init_model(sa_engine_db1)
 

	
 
    repos_path = make_ui('db').configitems('paths')[0][1]
rhodecode/controllers/admin/settings.py
Show inline comments
 
@@ -38,13 +38,13 @@ from pylons.i18n.translation import _
 
from rhodecode.lib import helpers as h
 
from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
 
    HasPermissionAnyDecorator, NotAnonymous
 
from rhodecode.lib.base import BaseController, render
 
from rhodecode.lib.celerylib import tasks, run_task
 
from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
 
    set_rhodecode_config, repo_name_slug
 
    set_rhodecode_config, repo_name_slug, check_git_version
 
from rhodecode.model.db import RhodeCodeUi, Repository, RepoGroup, \
 
    RhodeCodeSetting, PullRequest, PullRequestReviewers
 
from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
 
    ApplicationUiSettingsForm, ApplicationVisualisationForm
 
from rhodecode.model.scm import ScmModel
 
from rhodecode.model.user import UserModel
 
@@ -65,13 +65,14 @@ class SettingsController(BaseController)
 

	
 
    @LoginRequired()
 
    def __before__(self):
 
        c.admin_user = session.get('admin_user')
 
        c.admin_username = session.get('admin_username')
 
        c.modules = sorted([(p.project_name, p.version)
 
                            for p in pkg_resources.working_set],
 
                            for p in pkg_resources.working_set]
 
                           + [('git', check_git_version())],
 
                           key=lambda k: k[0].lower())
 
        c.py_version = platform.python_version()
 
        c.platform = platform.platform()
 
        super(SettingsController, self).__before__()
 

	
 
    @HasPermissionAllDecorator('hg.admin')
rhodecode/lib/utils.py
Show inline comments
 
@@ -669,6 +669,41 @@ class BasePasterCommand(Command):
 
        """
 
        from pylons import config as pylonsconfig
 

	
 
        self.path_to_ini_file = os.path.realpath(conf)
 
        conf = paste.deploy.appconfig('config:' + self.path_to_ini_file)
 
        pylonsconfig.init_app(conf.global_conf, conf.local_conf)
 

	
 

	
 
def check_git_version():
 
    """
 
    Checks what version of git is installed in system, and issues a warning
 
    if it's to old for RhodeCode to properly work.
 
    """
 
    import subprocess
 
    from distutils.version import StrictVersion
 
    from rhodecode import BACKENDS
 

	
 
    p = subprocess.Popen('git --version', shell=True,
 
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 
    stdout, stderr = p.communicate()
 
    ver = (stdout.split(' ')[-1] or '').strip() or '0.0.0'
 
    try:
 
        _ver = StrictVersion(ver)
 
    except:
 
        _ver = StrictVersion('0.0.0')
 
        stderr = traceback.format_exc()
 

	
 
    req_ver = '1.7.4'
 
    to_old_git = False
 
    if  _ver <= StrictVersion(req_ver):
 
        to_old_git = True
 

	
 
    if 'git' in BACKENDS:
 
        log.debug('GIT version detected: %s' % stdout)
 
        if stderr:
 
            log.warning('Unable to detect git version org error was:%r' % stderr)
 
        elif to_old_git:
 
            log.warning('RhodeCode detected git version %s, which is to old '
 
                        'for the system to function properly make sure '
 
                        'it is at least in version %s' % (ver, req_ver))
 
    return _ver
 
\ No newline at end of file
0 comments (0 inline, 0 general)