Changeset - 18d34a56a736
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2012-05-22 20:12:58
marcin@python-works.com
fix for issue #417, git execution was broken on windows for certain commands.
Added git as requirement into readme.
2 files changed with 19 insertions and 7 deletions:
0 comments (0 inline, 0 general)
docs/usage/git_support.rst
Show inline comments
 
.. _git_support:
 

	
 
===========
 
GIT support
 
===========
 

	
 

	
 
Git support in RhodeCode 1.3 was enabled by default. 
 
Git support in RhodeCode 1.3 was enabled by default. You need to have a git
 
client installed on the machine to make git fully work.
 

	
 
Although There are some limitations on git usage.
 

	
 
- No hooks are runned for git push/pull actions.
 
- logs in action journals don't have git operations
 
- hooks that are executed on pull/push are not *real* hooks, they are 
 
  just emulating the behavior, and are executed **BEFORE** action takes place.
 
- large pushes needs http server with chunked encoding support.
 
 
 
if you plan to use git you need to run RhodeCode with some
 
http server that supports chunked encoding which git http protocol uses, 
 
i recommend using waitress_ or gunicorn_ (linux only) for `paste` wsgi app 
 
replacement.
 

	
 
To use waitress simply change change the following in the .ini file::
 
To use, simply change change the following in the .ini file::
 

	
 
    use = egg:Paste#http
 

	
 
To::
 
to::
 
    
 
    use = egg:waitress#main
 

	
 
or::
 

	
 
    use = egg:gunicorn#main
 
    
 
    
 
And comment out bellow options::
 

	
 
    threadpool_workers = 
 
    threadpool_max_requests = 
 
    use_threadpool = 
 
    
 

	
 
You can simply run `paster serve` as usual.
 

	
 
  
 
You can always disable git/hg support by editing a 
 
file **rhodecode/__init__.py** and commenting out backends
 

	
 
.. code-block:: python
 
 
 
   BACKENDS = {
 
       'hg': 'Mercurial repository',
 
       #'git': 'Git repository',
 
   }
 

	
 
.. _waitress: http://pypi.python.org/pypi/waitress
 
.. _gunicorn: http://pypi.python.org/pypi/gunicorn
 
\ No newline at end of file
rhodecode/lib/vcs/backends/git/repository.py
Show inline comments
 
@@ -50,104 +50,109 @@ class GitRepository(BaseRepository):
 
        #temporary set that to now at later we will move it to constructor
 
        baseui = None
 
        if baseui is None:
 
            from mercurial.ui import ui
 
            baseui = ui()
 
        # patch the instance of GitRepo with an "FAKE" ui object to add
 
        # compatibility layer with Mercurial
 
        setattr(self._repo, 'ui', baseui)
 

	
 
        try:
 
            self.head = self._repo.head()
 
        except KeyError:
 
            self.head = None
 

	
 
        self._config_files = [
 
            bare and abspath(self.path, 'config') or abspath(self.path, '.git',
 
                'config'),
 
            abspath(get_user_home(), '.gitconfig'),
 
        ]
 
        self.bare = self._repo.bare
 

	
 
    @LazyProperty
 
    def revisions(self):
 
        """
 
        Returns list of revisions' ids, in ascending order.  Being lazy
 
        attribute allows external tools to inject shas from cache.
 
        """
 
        return self._get_all_revisions()
 

	
 
    def run_git_command(self, cmd):
 
        """
 
        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...
 

	
 
        :param cmd: git command to be executed
 
        """
 

	
 
        _copts = ['-c', 'core.quotepath=false', ]
 
        _str_cmd = False
 
        if isinstance(cmd, basestring):
 
            cmd = [cmd]
 
            _str_cmd = True
 

	
 
        cmd = ['GIT_CONFIG_NOGLOBAL=1', 'git'] + _copts + cmd
 
        gitenv = os.environ
 
        gitenv['GIT_CONFIG_NOGLOBAL'] = '1'
 

	
 
        cmd = ['git'] + _copts + cmd
 
        if _str_cmd:
 
            cmd = ' '.join(cmd)
 
        try:
 
            opts = dict(
 
                shell=isinstance(cmd, basestring),
 
                stdout=PIPE,
 
                stderr=PIPE)
 
                stderr=PIPE,
 
                env=gitenv,
 
            )
 
            if os.path.isdir(self.path):
 
                opts['cwd'] = self.path
 
            p = Popen(cmd, **opts)
 
        except OSError, err:
 
            raise RepositoryError("Couldn't run git command (%s).\n"
 
                "Original error was:%s" % (cmd, err))
 
        so, se = p.communicate()
 
        if not se.startswith("fatal: bad default revision 'HEAD'") and \
 
            p.returncode != 0:
 
            raise RepositoryError("Couldn't run git command (%s).\n"
 
                "stderr:\n%s" % (cmd, se))
 
        return so, se
 

	
 
    def _check_url(self, url):
 
        """
 
        Functon will check given url and try to verify if it's a valid
 
        link. Sometimes it may happened that mercurial will issue basic
 
        auth request that can cause whole API to hang when used from python
 
        or other external calls.
 

	
 
        On failures it'll raise urllib2.HTTPError
 
        """
 

	
 
        #TODO: implement this
 
        pass
 

	
 
    def _get_repo(self, create, src_url=None, update_after_clone=False,
 
            bare=False):
 
        if create and os.path.exists(self.path):
 
            raise RepositoryError("Location already exist")
 
        if src_url and not create:
 
            raise RepositoryError("Create should be set to True if src_url is "
 
                                  "given (clone operation creates repository)")
 
        try:
 
            if create and src_url:
 
                self._check_url(src_url)
 
                self.clone(src_url, update_after_clone, bare)
 
                return Repo(self.path)
 
            elif create:
 
                os.mkdir(self.path)
 
                if bare:
 
                    return Repo.init_bare(self.path)
 
                else:
 
                    return Repo.init(self.path)
 
            else:
 
                return Repo(self.path)
 
        except (NotGitRepository, OSError), err:
 
            raise RepositoryError(err)
0 comments (0 inline, 0 general)