Closed Nerian closed 12 years ago
The problem is here: https://github.com/wingrunr21/gitolite/blob/master/lib/gitolite/ssh_key.rb#L44
That's where the whitespace comes from.
In the mean time, this works:
admin_repo = Gitolite::GitoliteAdmin.new("gitolite-admin")
key = Gitolite::SSHKey.new("", public_key, "", "mike")
def key.to_s
@blob
end
admin_repo.add_key(key)
admin_repo.save_and_apply
The problem is because you are constructing the key incorrectly. If you look at https://github.com/wingrunr21/gitolite/blob/master/lib/gitolite/ssh_key.rb#L14, you can see that the constructor would require the ssh key string to be split first. So you would need to do this:
parts = public_key.split
key = Gitolite::SSHKey.new(*parts, 'mike')
The add_key_from_string method looks like a good idea. I will also add a from_string method to SSHKey so you can just pass a string to get an SSHKey object.
Thanks!
Implemented in 1887007dfc
key = Gitolite::SSHKey.from_string(some_string, 'owner')
There is not an add_key_from_string method. A GitoliteAdmin object is not responsible for that, it just wants a key. To add a key from a string do the above and add the key in the normal manner.
Hi Stafford,
Awesome Gem! Thanks for doing this.
I having some trouble adding a ssh key.
public_key
That end up actually adding this key:
Notice the whitespace at the start :)
So the key is not valid. I don't know if I am doing something wrong or there is a bug here. Please let me know what you think.
Also, what I would really like to be able to do is something like this:
Thanks!