class Gitolite::Config::Repo
Represents a repo inside the gitolite configuration. The name, permissions, and git config options are all encapsulated in this class
Constants
- ALLOWED_PERMISSIONS
Attributes
config[RW]
description[RW]
name[RW]
options[RW]
owner[RW]
permissions[RW]
Public Class Methods
new(name)
click to toggle source
# File lib/gitolite/config/repo.rb, line 12 def initialize(name) # Store the perm hash in a lambda since we have to create a new one on every deny rule # The perm hash is stored as a 2D hash, with individual permissions being the first # degree and individual refexes being the second degree. Both Hashes must respect order @perm_hash_lambda = lambda { Hash.new {|k,v| k[v] = Hash.new{|k2, v2| k2[v2] = [] }} } @permissions = Array.new.push(@perm_hash_lambda.call) @name = name @config = {} # git config @options = {} # gitolite config end
Public Instance Methods
add_permission(perm, refex = "", *users)
click to toggle source
# File lib/gitolite/config/repo.rb, line 30 def add_permission(perm, refex = "", *users) if perm =~ ALLOWED_PERMISSIONS #Handle deny rules if perm == '-' @permissions.push(@perm_hash_lambda.call) end @permissions.last[perm][refex].concat users.flatten @permissions.last[perm][refex].uniq! else raise InvalidPermissionError, "#{perm} is not in the allowed list of permissions!" end end
clean_permissions()
click to toggle source
# File lib/gitolite/config/repo.rb, line 25 def clean_permissions @permissions = Array.new.push(@perm_hash_lambda.call) end
gitweb_description()
click to toggle source
# File lib/gitolite/config/repo.rb, line 88 def gitweb_description if @description.nil? nil else desc = "#{@name} " desc += "\"#{@owner}\" " unless @owner.nil? desc += "= \"#{@description}\"" end end
set_git_config(key, value)
click to toggle source
# File lib/gitolite/config/repo.rb, line 45 def set_git_config(key, value) @config[key] = value end
set_gitolite_option(key, value)
click to toggle source
# File lib/gitolite/config/repo.rb, line 55 def set_gitolite_option(key, value) @options[key] = value end
to_s()
click to toggle source
# File lib/gitolite/config/repo.rb, line 65 def to_s repo = "repo #{@name}\n" @permissions.each do |perm_hash| perm_hash.each do |perm, list| list.each do |refex, users| repo += " " + perm.ljust(6) + refex.ljust(25) + "= " + users.join(' ') + "\n" end end end @config.each do |k, v| repo += " config " + k + " = " + v.to_s + "\n" end @options.each do |k, v| repo += " option " + k + " = " + v.to_s + "\n" end repo end
unset_git_config(key)
click to toggle source
# File lib/gitolite/config/repo.rb, line 50 def unset_git_config(key) @config.delete(key) end
unset_gitolite_option(key)
click to toggle source
# File lib/gitolite/config/repo.rb, line 60 def unset_gitolite_option(key) @options.delete(key) end