Closed albertoleal closed 12 years ago
Can you show me the code you are using?
I've just figure out what the problem is:
I was getting the repo with repo = @conf.get_repo(repo_name)
and then adding the permission into this repo. I could achieve what I wanted with repo = ::Gitolite::Config::Repo.new(repo_name)
.
Why I cannot use the other approach to run some changes on my repo? Is it a bug ?
No it is not a bug. In the first example you are getting the existing repo and adding a permission to it. Since that repo already has a permission, adding another permission does not replace the existing one. Thus, the repo now has two permissions.
In the second example you are creating a new repo and adding the permission. The new repo will have no permissions in it, so adding the R permission will be the only permission in the repo. Creating a new repo with the same name is not the same as fetching an existing repo by that name.
So, your use case is you have a repo with the following declaration:
repo alberto
RW+ = @all
and you want to change it to the following:
repo alberto
R = @all
correct?
Yes, that's exactly what I want to do. Change the permission for an specific user.
Right now you have three options:
clear all permissions on the existing repo:
repo = @conf.get_repo(repo_name)
repo.clean_permissions
repo.add_permission('R', '', '@all')
make a new repo and add permissions as you see fit
repo = ::Gitolite::Config::Repo.new(repo_name)
repo.add_permission('R', '', '@all')
You have brought to my attention that the Repo object is missing functionality for conveniently removing/updating perms. I will open an issue to try and address this.
What are the side effects on the # 2? (I'm using this now)
I tried the first option before opening this issue, but with that approach I lost the others permissions, and I do not want this.
You will just have to make sure you update the new repo object inside your config object:
# code to create new repo
@conf.rm_repo(repo_name)
@conf.add_repo(new_repo)
Otherwise there shouldn't be any side effects.
I think I got it. Gonna run some tests and let you know.
When I try add a permission to a user, RW+, and want to replace that to R I get the following:
repo alberto RW+ = @all R = @all
instead of:
repo alberto R = @all