diff options
author | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-23 11:50:02 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-23 11:50:02 -0800 |
commit | 3fddf300bd33b356540bee50ae17590ea9b61341 (patch) | |
tree | 8b17ce067dd67dc418ed06d023505523f243cb90 /lib/git | |
parent | f1366b39891402b0db9de661ad181089bfd79053 (diff) | |
download | third_party-ruby-git-3fddf300bd33b356540bee50ae17590ea9b61341.tar.gz third_party-ruby-git-3fddf300bd33b356540bee50ae17590ea9b61341.tar.xz third_party-ruby-git-3fddf300bd33b356540bee50ae17590ea9b61341.zip |
started the ruby-only command line git client
Diffstat (limited to 'lib/git')
-rw-r--r-- | lib/git/base.rb | 4 | ||||
-rw-r--r-- | lib/git/branches.rb | 12 | ||||
-rw-r--r-- | lib/git/lib.rb | 5 |
3 files changed, 19 insertions, 2 deletions
diff --git a/lib/git/base.rb b/lib/git/base.rb index 1820ee2..31ba9ff 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -429,6 +429,10 @@ module Git self.lib.revparse(objectish) end + def cat_file(objectish) + self.lib.object_contents(objectish) + end + # returns the name of the branch the working directory is currently on def current_branch self.lib.branch_current diff --git a/lib/git/branches.rb b/lib/git/branches.rb index 47d001a..60ab16b 100644 --- a/lib/git/branches.rb +++ b/lib/git/branches.rb @@ -41,5 +41,17 @@ module Git @branches[symbol.to_s] end + def to_s + out = '' + @branches.each do |k, b| + if b.current + out += "* " + b.to_s + "\n" + else + out += " " + b.to_s + "\n" + end + end + out + end + end end
\ No newline at end of file diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 9c6a041..120d9ce 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -81,7 +81,7 @@ module Git sha = revparse(opts[:object] || branch_current || 'master') count = opts[:count] || 30 - repo = Git::Raw::Repository.new(@git_dir) + repo = get_raw_repo return process_commit_data(repo.log(sha, count)) end @@ -182,7 +182,8 @@ module Git end def object_contents(sha) - command('cat-file', ['-p', sha]) + #command('cat-file', ['-p', sha]) + get_raw_repo.cat_file(revparse(sha)) end def ls_tree(sha) |