diff options
author | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-10 15:34:12 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-10 15:34:12 -0800 |
commit | efcce7fc123b9e64fb9d93224e4e78d09144af3d (patch) | |
tree | 5c9966a11b18218d6e2f655e7f34a7604530b2a1 /lib/git/base.rb | |
parent | fde3263abc5c7866aa7dce7aef28eacaa33d7664 (diff) | |
download | third_party-ruby-git-efcce7fc123b9e64fb9d93224e4e78d09144af3d.tar.gz third_party-ruby-git-efcce7fc123b9e64fb9d93224e4e78d09144af3d.tar.xz third_party-ruby-git-efcce7fc123b9e64fb9d93224e4e78d09144af3d.zip |
got clone and init to work - my first writing functions
Diffstat (limited to 'lib/git/base.rb')
-rw-r--r-- | lib/git/base.rb | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/lib/git/base.rb b/lib/git/base.rb index 1111887..00495c7 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -6,22 +6,26 @@ module Git @repository = nil @index = nil - # opens a Git Repository - no working directory options - def self.repo(git_dir) + # opens a bare Git Repository - no working directory options + def self.bare(git_dir) self.new :repository => git_dir end # opens a new Git Project from a working directory # you can specify non-standard git_dir and index file in the options def self.open(working_dir, opts={}) - default = {:working_directory => working_dir, - :repository => File.join(working_dir, '.git'), - :index => File.join(working_dir, '.git', 'index')} + default = {:working_directory => working_dir} git_options = default.merge(opts) self.new(git_options) end - + + # initializes a git repository + # + # options: + # :repository + # :index_file + # def self.init(working_dir, opts = {}) default = {:working_directory => working_dir, :repository => File.join(working_dir, '.git')} @@ -38,19 +42,36 @@ module Git self.new(git_options) end - def self.clone - raise NotImplementedError + # clones a git repository locally + # + # repository - http://repo.or.cz/w/sinatra.git + # name - sinatra + # + # options: + # :repository + # + # :bare + # or + # :working_directory + # :index_file + # + def self.clone(repository, name, opts = {}) + # run git-clone + self.new(Git::Lib.new.clone(repository, name, opts)) end def initialize(options = {}) + if working_dir = options[:working_directory] + options[:repository] = File.join(working_dir, '.git') if !options[:repository] + options[:index] = File.join(working_dir, '.git', 'index') if !options[:index] + end + @working_directory = Git::WorkingDirectory.new(options[:working_directory]) if options[:working_directory] @repository = Git::Repository.new(options[:repository]) if options[:repository] - @index = Git::Index.new(options[:index]) if options[:index] + @index = Git::Index.new(options[:index], false) if options[:index] end - - - + def dir @working_directory end |