summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/git.rb49
-rw-r--r--lib/git/base.rb59
-rw-r--r--lib/git/index.rb4
-rw-r--r--lib/git/path.rb23
-rw-r--r--lib/git/repository.rb5
-rw-r--r--lib/git/working_directory.rb4
6 files changed, 144 insertions, 0 deletions
diff --git a/lib/git.rb b/lib/git.rb
index 8d5c79f..25dc2b3 100644
--- a/lib/git.rb
+++ b/lib/git.rb
@@ -4,4 +4,53 @@
$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+require 'git/base'
+require 'git/path'
+#require 'git/lib'
+require 'git/repository'
+require 'git/index'
+require 'git/working_directory'
+
+=begin
+require 'git/object'
+
+require 'git/object/commit'
+require 'git/object/blob'
+require 'git/object/tree'
+require 'git/object/tag'
+
+require 'git/author'
+require 'git/ref'
+require 'git/file'
+
+require 'git/log'
+require 'git/sha'
+require 'git/diff'
+
+require 'git/branch'
+require 'git/remote'
+=end
+
+module Git
+
+ def self.repo(git_dir)
+ Base.repo(git_dir)
+ end
+
+ def self.open(working_dir, options = {})
+ Base.open(working_dir, options)
+ end
+
+ def clone
+ Base.clone()
+ end
+
+ def init(working_dir = '.')
+ Base.clone()
+ end
+
+end
+
+g = Git.open('/Users/schacon/Sites/glue')
+g = Git.repo('/Users/schacon/Sites/glue/.git')
diff --git a/lib/git/base.rb b/lib/git/base.rb
new file mode 100644
index 0000000..6eb3455
--- /dev/null
+++ b/lib/git/base.rb
@@ -0,0 +1,59 @@
+module Git
+
+ class Base
+
+ @working_directory = nil
+ @repository = nil
+ @index = nil
+
+ # opens a Git Repository - no working directory options
+ def self.repo(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')}
+ git_options = default.merge(opts)
+
+ self.new(git_options)
+ end
+
+ def initialize(options = {})
+ @working_directory = Git::Repository.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]
+ end
+
+ def self.clone
+ raise NotImplementedError
+ end
+
+ def self.init
+ raise NotImplementedError
+ end
+
+
+ def dir
+ @working_directory
+ end
+
+ def repo
+ @repository
+ end
+
+ def index
+ @index
+ end
+
+ private
+
+ def is_git_dir(dir)
+ end
+
+ end
+
+end \ No newline at end of file
diff --git a/lib/git/index.rb b/lib/git/index.rb
new file mode 100644
index 0000000..b96eedb
--- /dev/null
+++ b/lib/git/index.rb
@@ -0,0 +1,4 @@
+module Git
+ class Index < Git::Path
+ end
+end
diff --git a/lib/git/path.rb b/lib/git/path.rb
new file mode 100644
index 0000000..9d6ba49
--- /dev/null
+++ b/lib/git/path.rb
@@ -0,0 +1,23 @@
+module Git
+ class Path
+
+ attr_accessor :path
+
+ def initialize(path)
+ if File.exists?(path)
+ @path = path
+ else
+ raise ArgumentError, "path does not exist", path
+ end
+ end
+
+ def readable?
+ File.readable?(@path)
+ end
+
+ def writable?
+ File.writable?(@path)
+ end
+
+ end
+end \ No newline at end of file
diff --git a/lib/git/repository.rb b/lib/git/repository.rb
new file mode 100644
index 0000000..d76dc8b
--- /dev/null
+++ b/lib/git/repository.rb
@@ -0,0 +1,5 @@
+module Git
+ class Repository < Path
+
+ end
+end
diff --git a/lib/git/working_directory.rb b/lib/git/working_directory.rb
new file mode 100644
index 0000000..3f37f1a
--- /dev/null
+++ b/lib/git/working_directory.rb
@@ -0,0 +1,4 @@
+module Git
+ class WorkingDirectory < Git::Path
+ end
+end