changeset 3376:e67b2ef07a8e beta

git executable is now configurable via .ini files
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 17 Feb 2013 22:58:09 +0100
parents 7000fc4aa569
children 7d3d0a96e083
files development.ini production.ini rhodecode/config/deployment.ini_tmpl rhodecode/lib/middleware/pygrack.py rhodecode/lib/utils.py rhodecode/lib/vcs/backends/git/changeset.py rhodecode/lib/vcs/backends/git/repository.py
diffstat 7 files changed, 47 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/development.ini	Sun Feb 17 21:21:45 2013 +0100
+++ b/development.ini	Sun Feb 17 22:58:09 2013 +0100
@@ -43,6 +43,8 @@
 
 #WAITRESS
 threads = 5
+#100GB
+max_request_body_size = 107374182400
 use = egg:waitress#main
 
 host = 0.0.0.0
@@ -75,6 +77,9 @@
 dashboard_items = 100
 use_gravatar = true
 
+# path to git executable
+git_path = git
+
 ## RSS feed options
 
 rss_cut_off_limit = 256000
--- a/production.ini	Sun Feb 17 21:21:45 2013 +0100
+++ b/production.ini	Sun Feb 17 22:58:09 2013 +0100
@@ -43,6 +43,8 @@
 
 #WAITRESS
 threads = 5
+#100GB
+max_request_body_size = 107374182400
 use = egg:waitress#main
 
 host = 127.0.0.1
@@ -75,6 +77,9 @@
 dashboard_items = 100
 use_gravatar = true
 
+# path to git executable
+git_path = git
+
 ## RSS feed options
 
 rss_cut_off_limit = 256000
--- a/rhodecode/config/deployment.ini_tmpl	Sun Feb 17 21:21:45 2013 +0100
+++ b/rhodecode/config/deployment.ini_tmpl	Sun Feb 17 22:58:09 2013 +0100
@@ -43,6 +43,8 @@
 
 #WAITRESS
 threads = 5
+#100GB
+max_request_body_size = 107374182400
 use = egg:waitress#main
 
 host = 127.0.0.1
@@ -75,6 +77,9 @@
 dashboard_items = 100
 use_gravatar = true
 
+# path to git executable
+git_path = git
+
 ## RSS feed options
 
 rss_cut_off_limit = 256000
--- a/rhodecode/lib/middleware/pygrack.py	Sun Feb 17 21:21:45 2013 +0100
+++ b/rhodecode/lib/middleware/pygrack.py	Sun Feb 17 22:58:09 2013 +0100
@@ -6,6 +6,7 @@
 
 from webob import Request, Response, exc
 
+import rhodecode
 from rhodecode.lib import subprocessio
 
 log = logging.getLogger(__name__)
@@ -82,10 +83,11 @@
         # if you do add '\n' as part of data, count it.
         server_advert = '# service=%s' % git_command
         packet_len = str(hex(len(server_advert) + 4)[2:].rjust(4, '0')).lower()
+        _git_path = rhodecode.CONFIG.get('git_path', 'git')
         try:
             out = subprocessio.SubprocessIOChunker(
-                r'git %s --stateless-rpc --advertise-refs "%s"' % (
-                                git_command[4:], self.content_path),
+                r'%s %s --stateless-rpc --advertise-refs "%s"' % (
+                            _git_path, git_command[4:], self.content_path),
                 starting_values=[
                     packet_len + server_advert + '0000'
                 ]
@@ -142,8 +144,9 @@
         if git_command in [u'git-receive-pack']:
             # updating refs manually after each push.
             # Needed for pre-1.7.0.4 git clients using regular HTTP mode.
-            cmd = (u'git --git-dir "%s" '
-                    'update-server-info' % self.content_path)
+            _git_path = rhodecode.CONFIG.get('git_path', 'git')
+            cmd = (u'%s --git-dir "%s" '
+                    'update-server-info' % (_git_path, self.content_path))
             log.debug('handling cmd %s' % cmd)
             subprocess.call(cmd, shell=True)
 
--- a/rhodecode/lib/utils.py	Sun Feb 17 21:21:45 2013 +0100
+++ b/rhodecode/lib/utils.py	Sun Feb 17 22:58:09 2013 +0100
@@ -744,13 +744,12 @@
     Checks what version of git is installed in system, and issues a warning
     if it's too old for RhodeCode to properly work.
     """
-    import subprocess
+    from rhodecode import BACKENDS
+    from rhodecode.lib.vcs.backends.git.repository import GitRepository
     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()
+    stdout, stderr = GitRepository._run_git_command('--version')
+
     ver = (stdout.split(' ')[-1] or '').strip() or '0.0.0'
     if len(ver.split('.')) > 3:
         #StrictVersion needs to be only 3 element type
--- a/rhodecode/lib/vcs/backends/git/changeset.py	Sun Feb 17 21:21:45 2013 +0100
+++ b/rhodecode/lib/vcs/backends/git/changeset.py	Sun Feb 17 22:58:09 2013 +0100
@@ -2,6 +2,7 @@
 from itertools import chain
 from dulwich import objects
 from subprocess import Popen, PIPE
+import rhodecode
 from rhodecode.lib.vcs.conf import settings
 from rhodecode.lib.vcs.exceptions import RepositoryError
 from rhodecode.lib.vcs.exceptions import ChangesetError
@@ -362,8 +363,9 @@
             frmt = 'zip'
         else:
             frmt = 'tar'
-        cmd = 'git archive --format=%s --prefix=%s/ %s' % (frmt, prefix,
-            self.raw_id)
+        _git_path = rhodecode.CONFIG.get('git_path', 'git')
+        cmd = '%s archive --format=%s --prefix=%s/ %s' % (_git_path, 
+                                                frmt, prefix, self.raw_id)
         if kind == 'tgz':
             cmd += ' | gzip -9'
         elif kind == 'tbz2':
--- a/rhodecode/lib/vcs/backends/git/repository.py	Sun Feb 17 21:21:45 2013 +0100
+++ b/rhodecode/lib/vcs/backends/git/repository.py	Sun Feb 17 22:58:09 2013 +0100
@@ -20,7 +20,8 @@
 from dulwich.repo import Repo, NotGitRepository
 from dulwich.objects import Tag
 from string import Template
-from subprocess import Popen, PIPE
+
+import rhodecode
 from rhodecode.lib.vcs.backends.base import BaseRepository
 from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError
 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
@@ -91,17 +92,14 @@
         """
         return self._get_all_revisions()
 
-    def run_git_command(self, cmd):
+    @classmethod
+    def _run_git_command(cls, cmd, **opts):
         """
         Runs given ``cmd`` as git command and returns tuple
-        (returncode, stdout, stderr).
-
-        .. note::
-           This method exists only until log/blame functionality is implemented
-           at Dulwich (see https://bugs.launchpad.net/bugs/645142). Parsing
-           os command's output is road to hell...
+        (stdout, stderr).
 
         :param cmd: git command to be executed
+        :param opts: env options to pass into Subprocess command
         """
 
         _copts = ['-c', 'core.quotepath=false', ]
@@ -116,17 +114,17 @@
             del gitenv['GIT_DIR']
         gitenv['GIT_CONFIG_NOGLOBAL'] = '1'
 
-        cmd = ['git'] + _copts + cmd
+        _git_path = rhodecode.CONFIG.get('git_path', 'git')
+        cmd = [_git_path] + _copts + cmd
         if _str_cmd:
             cmd = ' '.join(cmd)
         try:
-            opts = dict(
+            _opts = dict(
                 env=gitenv,
                 shell=False,
             )
-            if os.path.isdir(self.path):
-                opts['cwd'] = self.path
-            p = subprocessio.SubprocessIOChunker(cmd, **opts)
+            _opts.update(opts)
+            p = subprocessio.SubprocessIOChunker(cmd, **_opts)
         except (EnvironmentError, OSError), err:
             log.error(traceback.format_exc())
             raise RepositoryError("Couldn't run git command (%s).\n"
@@ -134,6 +132,12 @@
 
         return ''.join(p.output), ''.join(p.error)
 
+    def run_git_command(self, cmd):
+        opts = {}
+        if os.path.isdir(self.path):
+            opts['cwd'] = self.path
+        return self._run_git_command(cmd, **opts)
+
     @classmethod
     def _check_url(cls, url):
         """