0

I want to allow pushing to the default branch only for certain users. Since Kallithea does not have this functionality built in my attempt was creating a hook that should provide that behavior. I know that Kallithea has a GUI for this but I wanted to use built in mercurial functionality and hgrc file in the repository.

I have a hook defined in .hg/hgrc file in a repository that is served through Kallithea SCM

[extensions]
acl = 

[hooks]
pretxnchangegroup.acl = python:hgext.acl.hook

[acl]
sources = push 

[acl.allow.branches]
default = myuser

This setting should allow push rights to default branch ONLY for 'myuser' but that is not happening. I'm not sure if the hook is not set up correctly or is Kallithea just skipping hooks defined in .hg/hgrc

Mario
  • 128
  • 7

1 Answers1

0

It's not clear how are you expecting this to work. I don't know much about acl extension, but I doubt it knows anything about Kallithea and its users, so I don't think it's going to work like this. I'd rather write a custom Python hook calling out to Kallithea to authorise users.

andrewsh
  • 1,115
  • 7
  • 12
  • Fair enough, it might be that Kallithea does not know about `acl` extension, but my question is in general, can hooks defined in .hg/hgrc work with Kallithea or is the only way to add a hook to Kallithea through GUI. If that is so then that's a drawback since hooks in Kallithea are Global for all repositories, and I want hooks per-repository. – Mario May 20 '16 at 09:44
  • At the moment yes, Kallithea supports only global hooks. Changing this is however relatively simple. – andrewsh Sep 24 '16 at 13:14
  • @ andrewsh .. when you say 'it's relatively simple', do you mean it's relatively simple to add to kallithea's source code so it can support this in the future or is it simple to somehow circumvent kallithea and define a hook differently, in which case, could you provide an example ? – Mario Oct 03 '16 at 08:46
  • I think both. I don't remember right now, but there're two bits of code in Kallithea, one of them makes use of hgrc options, and the other bit sets up the hooks. The first bit AFAIR filters out `[hooks]` section, and the other doesn't make use of it either — so fixing either bit of code would help, temporarily. – andrewsh Oct 04 '16 at 13:47
  • For a long-term solution, I think there was a pull request somewhere which added per-repository hooks, but as we didn't have proper database upgrade code ready at that moment, it hasn't been merged. We do now, using Alembic, so that PR should be revisited/reimplemented. – andrewsh Oct 04 '16 at 13:49
  • I think I found it https://bitbucket.org/conservancy/kallithea/pull-requests/39/allow-to-enable-or-disable-hooks-on-a-per/diff .. it hasn't been active for a while though, but it's good to hear there's hope for this one, would be a fantastic functionality :) – Mario Oct 07 '16 at 07:22