diff --git a/kallithea/controllers/admin/settings.py b/kallithea/controllers/admin/settings.py --- a/kallithea/controllers/admin/settings.py +++ b/kallithea/controllers/admin/settings.py @@ -109,12 +109,6 @@ class SettingsController(BaseController) sett = Ui.get_by_key('hooks', Ui.HOOK_REPO_SIZE) sett.ui_active = form_result['hooks_changegroup_repo_size'] - sett = Ui.get_by_key('hooks', Ui.HOOK_PUSH_LOG) - sett.ui_active = form_result['hooks_changegroup_push_logger'] - - sett = Ui.get_by_key('hooks', Ui.HOOK_PULL_LOG) - sett.ui_active = form_result['hooks_outgoing_pull_logger'] - ## EXTENSIONS sett = Ui.get_or_create('extensions', 'largefiles') sett.ui_active = form_result['extensions_largefiles'] diff --git a/kallithea/lib/db_manage.py b/kallithea/lib/db_manage.py --- a/kallithea/lib/db_manage.py +++ b/kallithea/lib/db_manage.py @@ -352,8 +352,6 @@ class DbManage(object): #('phases', 'publish', 'false', False) ('hooks', Ui.HOOK_UPDATE, 'hg update >&2', False), ('hooks', Ui.HOOK_REPO_SIZE, 'python:kallithea.lib.hooks.repo_size', True), - ('hooks', Ui.HOOK_PUSH_LOG, 'python:kallithea.lib.hooks.log_push_action', True), - ('hooks', Ui.HOOK_PULL_LOG, 'python:kallithea.lib.hooks.log_pull_action', True), ('extensions', 'largefiles', '', True), ('largefiles', 'usercache', os.path.join(path, '.cache', 'largefiles'), True), ('extensions', 'hgsubversion', '', False), diff --git a/kallithea/lib/hooks.py b/kallithea/lib/hooks.py --- a/kallithea/lib/hooks.py +++ b/kallithea/lib/hooks.py @@ -358,53 +358,51 @@ def handle_git_post_receive(repo_path, g # the post push hook should never use the cached instance scm_repo = repo.scm_instance_no_cache() - _hooks = dict(baseui.configitems('hooks')) or {} - # if push hook is enabled via web interface - if _hooks.get(Ui.HOOK_PUSH_LOG): - rev_data = [] - for l in git_stdin_lines: - old_rev, new_rev, ref = l.strip().split(' ') - _ref_data = ref.split('/') - if _ref_data[1] in ['tags', 'heads']: - rev_data.append({'old_rev': old_rev, - 'new_rev': new_rev, - 'ref': ref, - 'type': _ref_data[1], - 'name': '/'.join(_ref_data[2:])}) + rev_data = [] + for l in git_stdin_lines: + old_rev, new_rev, ref = l.strip().split(' ') + _ref_data = ref.split('/') + if _ref_data[1] in ['tags', 'heads']: + rev_data.append({'old_rev': old_rev, + 'new_rev': new_rev, + 'ref': ref, + 'type': _ref_data[1], + 'name': '/'.join(_ref_data[2:])}) - git_revs = [] - for push_ref in rev_data: - _type = push_ref['type'] - if _type == 'heads': - if push_ref['old_rev'] == EmptyChangeset().raw_id: - # update the symbolic ref if we push new repo - if scm_repo.is_empty(): - scm_repo._repo.refs.set_symbolic_ref('HEAD', - 'refs/heads/%s' % push_ref['name']) + git_revs = [] + for push_ref in rev_data: + _type = push_ref['type'] + if _type == 'heads': + if push_ref['old_rev'] == EmptyChangeset().raw_id: + # update the symbolic ref if we push new repo + if scm_repo.is_empty(): + scm_repo._repo.refs.set_symbolic_ref('HEAD', + 'refs/heads/%s' % push_ref['name']) - # build exclude list without the ref - cmd = ['for-each-ref', '--format=%(refname)', 'refs/heads/*'] - stdout, stderr = scm_repo.run_git_command(cmd) - ref = push_ref['ref'] - heads = [head for head in stdout.splitlines() if head != ref] - # now list the git revs while excluding from the list - cmd = ['log', push_ref['new_rev'], '--reverse', '--pretty=format:%H'] - cmd.append('--not') - cmd.extend(heads) # empty list is ok - stdout, stderr = scm_repo.run_git_command(cmd) - git_revs += stdout.splitlines() + # build exclude list without the ref + cmd = ['for-each-ref', '--format=%(refname)', 'refs/heads/*'] + stdout, stderr = scm_repo.run_git_command(cmd) + ref = push_ref['ref'] + heads = [head for head in stdout.splitlines() if head != ref] + # now list the git revs while excluding from the list + cmd = ['log', push_ref['new_rev'], '--reverse', '--pretty=format:%H'] + cmd.append('--not') + cmd.extend(heads) # empty list is ok + stdout, stderr = scm_repo.run_git_command(cmd) + git_revs += stdout.splitlines() - elif push_ref['new_rev'] == EmptyChangeset().raw_id: - # delete branch case - git_revs += ['delete_branch=>%s' % push_ref['name']] - else: - cmd = ['log', '%(old_rev)s..%(new_rev)s' % push_ref, - '--reverse', '--pretty=format:%H'] - stdout, stderr = scm_repo.run_git_command(cmd) - git_revs += stdout.splitlines() + elif push_ref['new_rev'] == EmptyChangeset().raw_id: + # delete branch case + git_revs += ['delete_branch=>%s' % push_ref['name']] + else: + cmd = ['log', '%(old_rev)s..%(new_rev)s' % push_ref, + '--reverse', '--pretty=format:%H'] + stdout, stderr = scm_repo.run_git_command(cmd) + git_revs += stdout.splitlines() - elif _type == 'tags': - git_revs += ['tag=>%s' % push_ref['name']] + elif _type == 'tags': + git_revs += ['tag=>%s' % push_ref['name']] - log_push_action(baseui, scm_repo, _git_revs=git_revs) + log_push_action(baseui, scm_repo, _git_revs=git_revs) + return 0 diff --git a/kallithea/lib/middleware/simplegit.py b/kallithea/lib/middleware/simplegit.py --- a/kallithea/lib/middleware/simplegit.py +++ b/kallithea/lib/middleware/simplegit.py @@ -196,6 +196,5 @@ class SimpleGit(BaseVCSController): _repo = Repository.get_by_repo_name(repo_name) _repo = _repo.scm_instance - _hooks = dict(baseui.configitems('hooks')) or {} - if action == 'pull' and _hooks.get(Ui.HOOK_PULL_LOG): + if action == 'pull': log_pull_action(ui=baseui, repo=_repo._repo) diff --git a/kallithea/lib/utils.py b/kallithea/lib/utils.py --- a/kallithea/lib/utils.py +++ b/kallithea/lib/utils.py @@ -364,6 +364,9 @@ def make_ui(read_from='file', path=None, # prevent interactive questions for ssh password / passphrase ssh = baseui.config('ui', 'ssh', default='ssh') baseui.setconfig('ui', 'ssh', '%s -oBatchMode=yes -oIdentitiesOnly=yes' % ssh) + # push / pull hooks + baseui.setconfig('hooks', 'changegroup.kallithea_log_push_action', 'python:kallithea.lib.hooks.log_push_action') + baseui.setconfig('hooks', 'outgoing.kallithea_log_pull_action', 'python:kallithea.lib.hooks.log_pull_action') return baseui diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -351,8 +351,6 @@ class Ui(Base, BaseDbModel): HOOK_UPDATE = 'changegroup.update' HOOK_REPO_SIZE = 'changegroup.repo_size' - HOOK_PUSH_LOG = 'changegroup.push_logger' - HOOK_PULL_LOG = 'outgoing.pull_logger' ui_id = Column(Integer(), primary_key=True) ui_section = Column(String(255), nullable=False) @@ -377,16 +375,14 @@ class Ui(Base, BaseDbModel): @classmethod def get_builtin_hooks(cls): q = cls.query() - q = q.filter(cls.ui_key.in_([cls.HOOK_UPDATE, cls.HOOK_REPO_SIZE, - cls.HOOK_PUSH_LOG, cls.HOOK_PULL_LOG])) + q = q.filter(cls.ui_key.in_([cls.HOOK_UPDATE, cls.HOOK_REPO_SIZE])) q = q.filter(cls.ui_section == 'hooks') return q.all() @classmethod def get_custom_hooks(cls): q = cls.query() - q = q.filter(~cls.ui_key.in_([cls.HOOK_UPDATE, cls.HOOK_REPO_SIZE, - cls.HOOK_PUSH_LOG, cls.HOOK_PULL_LOG])) + q = q.filter(~cls.ui_key.in_([cls.HOOK_UPDATE, cls.HOOK_REPO_SIZE])) q = q.filter(cls.ui_section == 'hooks') return q.all() diff --git a/kallithea/model/forms.py b/kallithea/model/forms.py --- a/kallithea/model/forms.py +++ b/kallithea/model/forms.py @@ -385,8 +385,6 @@ def ApplicationUiSettingsForm(): ) hooks_changegroup_update = v.StringBoolean(if_missing=False) hooks_changegroup_repo_size = v.StringBoolean(if_missing=False) - hooks_changegroup_push_logger = v.StringBoolean(if_missing=False) - hooks_outgoing_pull_logger = v.StringBoolean(if_missing=False) extensions_largefiles = v.StringBoolean(if_missing=False) extensions_hgsubversion = v.StringBoolean(if_missing=False) diff --git a/kallithea/templates/admin/settings/settings_vcs.html b/kallithea/templates/admin/settings/settings_vcs.html --- a/kallithea/templates/admin/settings/settings_vcs.html +++ b/kallithea/templates/admin/settings/settings_vcs.html @@ -11,18 +11,6 @@ ${h.form(url('admin_settings'), method='