Skip to content

Commit 1d84579

Browse files
committed
reverted the pure ruby code to system calls and split the pure ruby to a new library
1 parent 2d749e3 commit 1d84579

File tree

13 files changed

+15
-1050
lines changed

13 files changed

+15
-1050
lines changed

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Git::Remote - A reference to a remote repository that is tracked by this reposit
4848
Git::Log - An Enumerable object that references all the Git::Object::Commit objects that encompass
4949
your log query, which can be constructed through methods on the Git::Log object, like:
5050

51-
@git.log(20).object("HEAD^").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }
51+
@git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }
5252

5353
= Gitr
5454

bin/gitr

Lines changed: 0 additions & 78 deletions
This file was deleted.

lib/git.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
require 'git/stashes'
2727
require 'git/stash'
2828

29-
require 'git/raw/repository'
30-
3129

3230
# Git/Ruby Library
3331
#

lib/git/lib.rb

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class Lib
1313
@path = nil
1414

1515
@logger = nil
16-
@raw_repo = nil
1716

1817
def initialize(base = nil, logger = nil)
1918
if base.is_a?(Git::Base)
@@ -76,17 +75,6 @@ def log_commits(opts = {})
7675
end
7776

7877
def full_log_commits(opts = {})
79-
if !(opts[:since] || opts[:between] || opts[:path_limiter])
80-
# can do this in pure ruby
81-
sha = revparse(opts[:object] || branch_current || 'master')
82-
count = opts[:count] || 30
83-
84-
if /\w{40}$/.match(sha) # valid sha
85-
repo = get_raw_repo
86-
return process_commit_data(repo.log(sha, count))
87-
end
88-
end
89-
9078
arr_opts = ['--pretty=raw']
9179
arr_opts << "-#{opts[:count]}" if opts[:count]
9280
arr_opts << "--since=\"#{opts[:since]}\"" if opts[:since].is_a? String
@@ -126,16 +114,11 @@ def object_type(sha)
126114
def object_size(sha)
127115
command('cat-file', ['-s', sha]).to_i
128116
end
129-
130-
def get_raw_repo
131-
@raw_repo ||= Git::Raw::Repository.new(@git_dir)
132-
end
133117

134118
# returns useful array of raw commit object data
135119
def commit_data(sha)
136120
sha = sha.to_s
137-
cdata = get_raw_repo.cat_file(revparse(sha))
138-
#cdata = command_lines('cat-file', ['commit', sha])
121+
cdata = command_lines('cat-file', ['commit', sha])
139122
process_commit_data(cdata, sha)
140123
end
141124

@@ -184,22 +167,17 @@ def process_commit_data(data, sha = nil)
184167
end
185168

186169
def object_contents(sha)
187-
#command('cat-file', ['-p', sha])
188-
get_raw_repo.cat_file(revparse(sha)).chomp
170+
command('cat-file', ['-p', sha])
189171
end
190172

191173
def ls_tree(sha)
192174
data = {'blob' => {}, 'tree' => {}}
193175

194-
get_raw_repo.object(revparse(sha)).entry.each do |e|
195-
data[e.format_type][e.name] = {:mode => e.format_mode, :sha => e.sha1}
176+
command_lines('ls-tree', sha.to_s).each do |line|
177+
(info, filenm) = line.split("\t")
178+
(mode, type, sha) = info.split
179+
data[type][filenm] = {:mode => mode, :sha => sha}
196180
end
197-
198-
#command_lines('ls-tree', sha.to_s).each do |line|
199-
# (info, filenm) = line.split("\t")
200-
# (mode, type, sha) = info.split
201-
# data[type][filenm] = {:mode => mode, :sha => sha}
202-
#end
203181

204182
data
205183
end
@@ -438,7 +416,7 @@ def branch_new(branch)
438416
end
439417

440418
def branch_delete(branch)
441-
command('branch', ['-d', branch])
419+
command('branch', ['-D', branch])
442420
end
443421

444422
def checkout(branch, opts = {})
@@ -497,11 +475,7 @@ def remotes
497475
end
498476

499477
def tags
500-
tag_dir = File.join(@git_dir, 'refs', 'tags')
501-
tags = []
502-
Dir.chdir(tag_dir) { tags = Dir.glob('*') }
503-
return tags
504-
#command_lines('tag')
478+
command_lines('tag')
505479
end
506480

507481
def tag(tag)

lib/git/raw/internal/loose.rb

Lines changed: 0 additions & 110 deletions
This file was deleted.

lib/git/raw/internal/mmap.rb

Lines changed: 0 additions & 58 deletions
This file was deleted.

lib/git/raw/internal/object.rb

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)