Search code examples
gitolite

Gitolite macro to expand to user name?


I have a config file with something like:

repo qt/[a-zA-Z0-9_\.\-]+
  C      = @admins
  RW+    = @admins
  R      = @users
  RW bob = bob

As you can see every user (in group @users) can read all branches and I want bob to be able to create and push to a branch bob (and also to bob/fix and so on).

Is there a macro that would expand to the users name? I would like to do something like:

repo qt/[a-zA-Z0-9_\.\-]+
  C       = @admins
  RW+     = @admins
  R       = @users
  RW USER = USER

Solution

  • The one Gitolite feature which would look close to what you want is "personal branch"

    "Personal" branches are great for environments where developers need to share work but can't directly pull from each other (usually due to either a networking or authentication related reason, both common in corporate setups).

    Personal branches exist in a namespace of their own. The syntax is

    RW+ personal/USER/  =   @userlist
    

    where the "personal" can be anything you like (but cannot be empty), and the "/USER/" part is necessary (including both slashes).

    A user "alice" (if she's in the userlist) can then push any branches inside personal/alice/.
    Which means she can push personal/alice/foo and personal/alice/bar, but NOT personal/alice.

    (Background: at runtime the "USER" component will be replaced by the name of the invoking user. Access is determined by the right hand side, as usual).

    That means, when you are looking for "Is there a macro that would expand to the users name?", /USER/ would be an example of a "macro" expended to the username.