Changeset - 8a68e0292232
[Not reviewed]
beta
0 6 0
Marcin Kuzminski - 13 years ago 2012-06-06 22:23:27
marcin@python-works.com
Change git & hg hooks to post. They shouldn't block as they are used just for logging actions. Futhermore post hooks have access to changesets, so it's much better flexible
6 files changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/hooks.py
Show inline comments
 
@@ -138,7 +138,7 @@ def log_push_action(ui, repo, **kwargs):
 

	
 
        stop, start = get_revs(repo, [node + ':'])
 
        h = binascii.hexlify
 
        revs = (h(repo[r].node()) for r in xrange(start, stop + 1))
 
        revs = [h(repo[r].node()) for r in xrange(start, stop + 1)]
 
    elif scm == 'git':
 
        revs = kwargs.get('_git_revs', [])
 
        if '_git_revs' in kwargs:
 
@@ -198,7 +198,7 @@ def log_create_repository(repository_dic
 

	
 
def handle_git_post_receive(repo_path, revs, env):
 
    """
 
    A really hacky method that is runned by git pre-receive hook and logs
 
    A really hacky method that is runned by git post-receive hook and logs
 
    an push action together with pushed revisions. It's runned by subprocess
 
    thus needs all info to be able to create a temp pylons enviroment, connect
 
    to database and run the logging code. Hacky as sh**t but works. ps.
rhodecode/lib/middleware/simplegit.py
Show inline comments
 
@@ -271,7 +271,7 @@ class SimpleGit(BaseVCSController):
 

	
 
    def _handle_githooks(self, repo_name, action, baseui, environ):
 
        """
 
        Handles pull action, push is handled by pre-receive hook
 
        Handles pull action, push is handled by post-receive hook
 
        """
 
        from rhodecode.lib.hooks import log_pull_action
 
        service = environ['QUERY_STRING'].split('=')
rhodecode/model/db.py
Show inline comments
 
@@ -238,7 +238,7 @@ class RhodeCodeUi(Base, BaseModel):
 

	
 
    HOOK_UPDATE = 'changegroup.update'
 
    HOOK_REPO_SIZE = 'changegroup.repo_size'
 
    HOOK_PUSH = 'pretxnchangegroup.push_logger'
 
    HOOK_PUSH = 'changegroup.push_logger'
 
    HOOK_PULL = 'preoutgoing.pull_logger'
 

	
 
    ui_id = Column("ui_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
rhodecode/model/forms.py
Show inline comments
 
@@ -731,7 +731,7 @@ def ApplicationUiSettingsForm():
 
        paths_root_path = All(ValidPath(), UnicodeString(strip=True, min=1, not_empty=True))
 
        hooks_changegroup_update = OneOf(['True', 'False'], if_missing=False)
 
        hooks_changegroup_repo_size = OneOf(['True', 'False'], if_missing=False)
 
        hooks_pretxnchangegroup_push_logger = OneOf(['True', 'False'], if_missing=False)
 
        hooks_changegroup_push_logger = OneOf(['True', 'False'], if_missing=False)
 
        hooks_preoutgoing_pull_logger = OneOf(['True', 'False'], if_missing=False)
 

	
 
    return _ApplicationUiSettingsForm
rhodecode/model/repo.py
Show inline comments
 
@@ -476,7 +476,7 @@ class RepoModel(BaseModel):
 
            tmpl = pkg_resources.resource_string(
 
                'rhodecode', jn('config', 'pre_receive_tmpl.py')
 
            )
 
            _hook_file = jn(loc, 'pre-receive')
 
            _hook_file = jn(loc, 'post-receive')
 
            with open(_hook_file, 'wb') as f:
 
                f.write(tmpl)
 
            os.chmod(_hook_file, 0555)
rhodecode/templates/admin/settings/settings.html
Show inline comments
 
@@ -148,8 +148,8 @@
 
						<label for="hooks_changegroup_repo_size">${_('Show repository size after push')}</label>
 
					</div>
 
                    <div class="checkbox">
 
                        ${h.checkbox('hooks_pretxnchangegroup_push_logger','True')}
 
                        <label for="hooks_pretxnchangegroup_push_logger">${_('Log user push commands')}</label>
 
                        ${h.checkbox('hooks_changegroup_push_logger','True')}
 
                        <label for="hooks_changegroup_push_logger">${_('Log user push commands')}</label>
 
                    </div>
 
                    <div class="checkbox">
 
                        ${h.checkbox('hooks_preoutgoing_pull_logger','True')}
0 comments (0 inline, 0 general)