Marcin Kuzminski avatar Marcin Kuzminski committed 84414d7

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

Comments (0)

Files changed (3)

rhodecode/config/environment.py

 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
         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.')

rhodecode/controllers/admin/settings.py

 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, \
         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()

rhodecode/lib/utils.py

         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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.