Skip to content

Commit

Permalink
README updates and rm_repo now accepts a symbol or string
Browse files Browse the repository at this point in the history
  • Loading branch information
wingrunr21 committed Jul 15, 2011
1 parent 0228137 commit 142c2e4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
44 changes: 35 additions & 9 deletions README.rdoc
Expand Up @@ -30,28 +30,55 @@ This gem is still under very active development. There are a number of issues w

This method can only be called on an existing gitolite-admin repo. If you need to create a new gitolite-admin repo, see "Bootstrapping".

=== Configuration Files

conf = ga_repo.config

#Empty configs can also be initialized
conf2 = Config.init # => defaults to a filename of gitolite.conf
conf2 = Config.init("new_config.conf")

#Filename is set to whatever the filename was when the config was created
conf.filename # => "gitolite.conf"
conf2.filename # => "new_config.conf")

#filename can be changed via the setter
conf2.filename = "new_config.conf"

#to_file will write the config out to the file system
#using the value of the filename attribute. An alternative
#filename can also be specified
conf.to_file("/new/config/path") # => writes /new/config/path/gitolite.conf
conf.to_file("/new/config/path", "test.conf") # => writes /new/config/path/test.conf

=== Repo management

repo = Gitolite::Config::Repo.new("AwesomeRepo")

#For a list of permissions, see https://github.com/sitaramc/gitolite/blob/pu/doc/gitolite.conf.mkd
repo.add_permission("RW+", "", "bob", "joe", "susan")

#Add repo
ga_repo.config.add_repo(repo)
#Add repo to config
conf.add_repo(repo)

#Delete repo by object
conf.rm_repo(repo)

#Delete repo
ga_repo.config.rm_repo(repo)
#Delete a repo by name
conf.rm_repo("AwesomeRepo")
conf.rm_repo(:AwesomeRepo)

#Test if repo exists
ga_repo.config.has_repo?('cool_repo')
#Test if repo exists by name
conf.has_repo?('cool_repo') # => false
conf.has_repo?(:cool_repo) # => false

#Can also pass a Gitolite::Config::Repo object
repo = Gitolite::Config::Repo.new('cool_repo')
ga_repo.config.has_repo?(repo)
conf.has_repo?(repo) # => true

#Get a repo object from the config
repo = ga_repo.config.get_repo('cool_repo')
repo = conf.get_repo('cool_repo')
repo = conf.get_repo(:cool_repo)

=== SSH Key Management

Expand Down Expand Up @@ -114,4 +141,3 @@ Because the gem is still pre-release, I'd prefer not to take pull requests at th
* Rails integration
* Make the gem thread safe
* Add full support for Wildcard repos
* support git config options
7 changes: 5 additions & 2 deletions lib/gitolite/config.rb
Expand Up @@ -95,8 +95,11 @@ def add_repo(repo, overwrite = false)
end

def rm_repo(repo)
raise ArgumentError, "Repo must be of type Gitolite::Config::Repo!" unless repo.instance_of? Gitolite::Config::Repo
@repos.delete repo.name
if repo.instance_of?(Gitolite::Config::Repo)
@repos.delete(repo.name)
else
repo.is_a?(Symbol) ? @repos.delete(repo.to_s) : @repos.delete(repo)
end
end

def has_repo?(repo)
Expand Down

0 comments on commit 142c2e4

Please sign in to comment.