##// END OF EJS Templates
git executable is now configurable via .ini files
marcink -
r3376:e67b2ef0 beta
parent child Browse files
Show More
@@ -43,6 +43,8 b' pdebug = false'
43
43
44 #WAITRESS
44 #WAITRESS
45 threads = 5
45 threads = 5
46 #100GB
47 max_request_body_size = 107374182400
46 use = egg:waitress#main
48 use = egg:waitress#main
47
49
48 host = 0.0.0.0
50 host = 0.0.0.0
@@ -75,6 +77,9 b' commit_parse_limit = 25'
75 dashboard_items = 100
77 dashboard_items = 100
76 use_gravatar = true
78 use_gravatar = true
77
79
80 # path to git executable
81 git_path = git
82
78 ## RSS feed options
83 ## RSS feed options
79
84
80 rss_cut_off_limit = 256000
85 rss_cut_off_limit = 256000
@@ -43,6 +43,8 b' pdebug = false'
43
43
44 #WAITRESS
44 #WAITRESS
45 threads = 5
45 threads = 5
46 #100GB
47 max_request_body_size = 107374182400
46 use = egg:waitress#main
48 use = egg:waitress#main
47
49
48 host = 127.0.0.1
50 host = 127.0.0.1
@@ -75,6 +77,9 b' commit_parse_limit = 50'
75 dashboard_items = 100
77 dashboard_items = 100
76 use_gravatar = true
78 use_gravatar = true
77
79
80 # path to git executable
81 git_path = git
82
78 ## RSS feed options
83 ## RSS feed options
79
84
80 rss_cut_off_limit = 256000
85 rss_cut_off_limit = 256000
@@ -43,6 +43,8 b' pdebug = false'
43
43
44 #WAITRESS
44 #WAITRESS
45 threads = 5
45 threads = 5
46 #100GB
47 max_request_body_size = 107374182400
46 use = egg:waitress#main
48 use = egg:waitress#main
47
49
48 host = 127.0.0.1
50 host = 127.0.0.1
@@ -75,6 +77,9 b' commit_parse_limit = 50'
75 dashboard_items = 100
77 dashboard_items = 100
76 use_gravatar = true
78 use_gravatar = true
77
79
80 # path to git executable
81 git_path = git
82
78 ## RSS feed options
83 ## RSS feed options
79
84
80 rss_cut_off_limit = 256000
85 rss_cut_off_limit = 256000
@@ -6,6 +6,7 b' import traceback'
6
6
7 from webob import Request, Response, exc
7 from webob import Request, Response, exc
8
8
9 import rhodecode
9 from rhodecode.lib import subprocessio
10 from rhodecode.lib import subprocessio
10
11
11 log = logging.getLogger(__name__)
12 log = logging.getLogger(__name__)
@@ -82,10 +83,11 b' class GitRepository(object):'
82 # if you do add '\n' as part of data, count it.
83 # if you do add '\n' as part of data, count it.
83 server_advert = '# service=%s' % git_command
84 server_advert = '# service=%s' % git_command
84 packet_len = str(hex(len(server_advert) + 4)[2:].rjust(4, '0')).lower()
85 packet_len = str(hex(len(server_advert) + 4)[2:].rjust(4, '0')).lower()
86 _git_path = rhodecode.CONFIG.get('git_path', 'git')
85 try:
87 try:
86 out = subprocessio.SubprocessIOChunker(
88 out = subprocessio.SubprocessIOChunker(
87 r'git %s --stateless-rpc --advertise-refs "%s"' % (
89 r'%s %s --stateless-rpc --advertise-refs "%s"' % (
88 git_command[4:], self.content_path),
90 _git_path, git_command[4:], self.content_path),
89 starting_values=[
91 starting_values=[
90 packet_len + server_advert + '0000'
92 packet_len + server_advert + '0000'
91 ]
93 ]
@@ -142,8 +144,9 b' class GitRepository(object):'
142 if git_command in [u'git-receive-pack']:
144 if git_command in [u'git-receive-pack']:
143 # updating refs manually after each push.
145 # updating refs manually after each push.
144 # Needed for pre-1.7.0.4 git clients using regular HTTP mode.
146 # Needed for pre-1.7.0.4 git clients using regular HTTP mode.
145 cmd = (u'git --git-dir "%s" '
147 _git_path = rhodecode.CONFIG.get('git_path', 'git')
146 'update-server-info' % self.content_path)
148 cmd = (u'%s --git-dir "%s" '
149 'update-server-info' % (_git_path, self.content_path))
147 log.debug('handling cmd %s' % cmd)
150 log.debug('handling cmd %s' % cmd)
148 subprocess.call(cmd, shell=True)
151 subprocess.call(cmd, shell=True)
149
152
@@ -744,13 +744,12 b' def check_git_version():'
744 Checks what version of git is installed in system, and issues a warning
744 Checks what version of git is installed in system, and issues a warning
745 if it's too old for RhodeCode to properly work.
745 if it's too old for RhodeCode to properly work.
746 """
746 """
747 import subprocess
747 from rhodecode import BACKENDS
748 from rhodecode.lib.vcs.backends.git.repository import GitRepository
748 from distutils.version import StrictVersion
749 from distutils.version import StrictVersion
749 from rhodecode import BACKENDS
750
750
751 p = subprocess.Popen('git --version', shell=True,
751 stdout, stderr = GitRepository._run_git_command('--version')
752 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
752
753 stdout, stderr = p.communicate()
754 ver = (stdout.split(' ')[-1] or '').strip() or '0.0.0'
753 ver = (stdout.split(' ')[-1] or '').strip() or '0.0.0'
755 if len(ver.split('.')) > 3:
754 if len(ver.split('.')) > 3:
756 #StrictVersion needs to be only 3 element type
755 #StrictVersion needs to be only 3 element type
@@ -2,6 +2,7 b' import re'
2 from itertools import chain
2 from itertools import chain
3 from dulwich import objects
3 from dulwich import objects
4 from subprocess import Popen, PIPE
4 from subprocess import Popen, PIPE
5 import rhodecode
5 from rhodecode.lib.vcs.conf import settings
6 from rhodecode.lib.vcs.conf import settings
6 from rhodecode.lib.vcs.exceptions import RepositoryError
7 from rhodecode.lib.vcs.exceptions import RepositoryError
7 from rhodecode.lib.vcs.exceptions import ChangesetError
8 from rhodecode.lib.vcs.exceptions import ChangesetError
@@ -362,8 +363,9 b' class GitChangeset(BaseChangeset):'
362 frmt = 'zip'
363 frmt = 'zip'
363 else:
364 else:
364 frmt = 'tar'
365 frmt = 'tar'
365 cmd = 'git archive --format=%s --prefix=%s/ %s' % (frmt, prefix,
366 _git_path = rhodecode.CONFIG.get('git_path', 'git')
366 self.raw_id)
367 cmd = '%s archive --format=%s --prefix=%s/ %s' % (_git_path,
368 frmt, prefix, self.raw_id)
367 if kind == 'tgz':
369 if kind == 'tgz':
368 cmd += ' | gzip -9'
370 cmd += ' | gzip -9'
369 elif kind == 'tbz2':
371 elif kind == 'tbz2':
@@ -20,7 +20,8 b' import urllib2'
20 from dulwich.repo import Repo, NotGitRepository
20 from dulwich.repo import Repo, NotGitRepository
21 from dulwich.objects import Tag
21 from dulwich.objects import Tag
22 from string import Template
22 from string import Template
23 from subprocess import Popen, PIPE
23
24 import rhodecode
24 from rhodecode.lib.vcs.backends.base import BaseRepository
25 from rhodecode.lib.vcs.backends.base import BaseRepository
25 from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError
26 from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError
26 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
27 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
@@ -91,17 +92,14 b' class GitRepository(BaseRepository):'
91 """
92 """
92 return self._get_all_revisions()
93 return self._get_all_revisions()
93
94
94 def run_git_command(self, cmd):
95 @classmethod
96 def _run_git_command(cls, cmd, **opts):
95 """
97 """
96 Runs given ``cmd`` as git command and returns tuple
98 Runs given ``cmd`` as git command and returns tuple
97 (returncode, stdout, stderr).
99 (stdout, stderr).
98
99 .. note::
100 This method exists only until log/blame functionality is implemented
101 at Dulwich (see https://bugs.launchpad.net/bugs/645142). Parsing
102 os command's output is road to hell...
103
100
104 :param cmd: git command to be executed
101 :param cmd: git command to be executed
102 :param opts: env options to pass into Subprocess command
105 """
103 """
106
104
107 _copts = ['-c', 'core.quotepath=false', ]
105 _copts = ['-c', 'core.quotepath=false', ]
@@ -116,17 +114,17 b' class GitRepository(BaseRepository):'
116 del gitenv['GIT_DIR']
114 del gitenv['GIT_DIR']
117 gitenv['GIT_CONFIG_NOGLOBAL'] = '1'
115 gitenv['GIT_CONFIG_NOGLOBAL'] = '1'
118
116
119 cmd = ['git'] + _copts + cmd
117 _git_path = rhodecode.CONFIG.get('git_path', 'git')
118 cmd = [_git_path] + _copts + cmd
120 if _str_cmd:
119 if _str_cmd:
121 cmd = ' '.join(cmd)
120 cmd = ' '.join(cmd)
122 try:
121 try:
123 opts = dict(
122 _opts = dict(
124 env=gitenv,
123 env=gitenv,
125 shell=False,
124 shell=False,
126 )
125 )
127 if os.path.isdir(self.path):
126 _opts.update(opts)
128 opts['cwd'] = self.path
127 p = subprocessio.SubprocessIOChunker(cmd, **_opts)
129 p = subprocessio.SubprocessIOChunker(cmd, **opts)
130 except (EnvironmentError, OSError), err:
128 except (EnvironmentError, OSError), err:
131 log.error(traceback.format_exc())
129 log.error(traceback.format_exc())
132 raise RepositoryError("Couldn't run git command (%s).\n"
130 raise RepositoryError("Couldn't run git command (%s).\n"
@@ -134,6 +132,12 b' class GitRepository(BaseRepository):'
134
132
135 return ''.join(p.output), ''.join(p.error)
133 return ''.join(p.output), ''.join(p.error)
136
134
135 def run_git_command(self, cmd):
136 opts = {}
137 if os.path.isdir(self.path):
138 opts['cwd'] = self.path
139 return self._run_git_command(cmd, **opts)
140
137 @classmethod
141 @classmethod
138 def _check_url(cls, url):
142 def _check_url(cls, url):
139 """
143 """
General Comments 0
You need to be logged in to leave comments. Login now