Skip to content

Commit 7dc56e1

Browse files
author
scott Chacon
committed
added some TODO notes, the History.txt entry i forgot and a way to attach a custom logger to Git
1 parent c478613 commit 7dc56e1

File tree

7 files changed

+35
-14
lines changed

7 files changed

+35
-14
lines changed

History.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
== 1.0.4
2+
3+
* added camping/gitweb.rb frontend
4+
* added a number of speed-ups
5+
16
== 1.0.3
27

38
* Sped up most of the operations

TODO

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- prune, fsck, pack-refs, gc, count-objects, unpack-objects
1616

1717
* email/patch integration
18-
- request-pull(email_address), git-am, git-apply
18+
- request-pull(email_address), git-am, git-apply, cherry-pick
1919

2020

2121
* compatible with git 1.4

benchmark.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require 'benchmark'
33
require 'rubygems'
44
require 'ruby-prof'
5-
require_gem 'git', '1.0.3'
6-
#require 'lib/git'
5+
#require_gem 'git', '1.0.3'
6+
require 'lib/git'
77

88
def main
99
@wbare = File.expand_path(File.join('tests', 'files', 'working.git'))

camping/gitweb.rb

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#
1313
# todo
1414
# - diff/patch between any two objects
15+
# - prettify : http://projects.wh.techno-weenie.net/changesets/3030
16+
# - add user model (add/remove repos)
17+
# - implement http-push for authenticated users
1518
#
1619
# author : scott chacon
1720
#

lib/git.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ module Git
4848
# it expects not to be able to use a working directory
4949
# so you can't checkout stuff, commit things, etc.
5050
# but you can do most read operations
51-
def self.bare(git_dir)
52-
Base.bare(git_dir)
51+
def self.bare(git_dir, options = {})
52+
Base.bare(git_dir, options)
5353
end
5454

5555
# open an existing git working directory

lib/git/base.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ class Base
77
@index = nil
88

99
@lib = nil
10+
@logger = nil
1011

1112
# opens a bare Git Repository - no working directory options
12-
def self.bare(git_dir)
13-
self.new :repository => git_dir
13+
def self.bare(git_dir, opts = {})
14+
default = {:repository => git_dir}
15+
git_options = default.merge(opts)
16+
17+
self.new(git_options)
1418
end
1519

1620
# opens a new Git Project from a working directory
@@ -67,6 +71,9 @@ def initialize(options = {})
6771
options[:repository] = File.join(working_dir, '.git') if !options[:repository]
6872
options[:index] = File.join(working_dir, '.git', 'index') if !options[:index]
6973
end
74+
if options[:log]
75+
@logger = options[:log]
76+
end
7077

7178
@working_directory = Git::WorkingDirectory.new(options[:working_directory]) if options[:working_directory]
7279
@repository = Git::Repository.new(options[:repository]) if options[:repository]
@@ -199,7 +206,7 @@ def remote(remote_name = 'origin')
199206
# actual 'git' forked system calls. At some point I hope to replace the Git::Lib
200207
# class with one that uses native methods or libgit C bindings
201208
def lib
202-
@lib ||= Git::Lib.new(self)
209+
@lib ||= Git::Lib.new(self, @logger)
203210
end
204211

205212
# will run a grep for 'string' on the HEAD of the git repository

lib/git/lib.rb

+12-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ class Lib
1111
@git_index_file = nil
1212
@git_work_dir = nil
1313
@path = nil
14-
15-
def initialize(base = nil)
14+
15+
@logger = nil
16+
17+
def initialize(base = nil, logger = nil)
1618
if base.is_a?(Git::Base)
1719
@git_dir = base.repo.path
1820
@git_index_file = base.index.path if base.index
@@ -22,6 +24,9 @@ def initialize(base = nil)
2224
@git_index_file = base[:index]
2325
@git_work_dir = base[:working_directory]
2426
end
27+
if logger
28+
@logger = logger
29+
end
2530
end
2631

2732
def init
@@ -481,10 +486,11 @@ def command(cmd, opts = {}, chdir = true)
481486
out = `git #{cmd} #{opts} 2>&1`.chomp
482487
end
483488

484-
#puts git_cmd
485-
#puts out
486-
#puts
487-
489+
if @logger
490+
@logger.info(git_cmd)
491+
@logger.debug(out)
492+
end
493+
488494
if $?.exitstatus > 0
489495
if $?.exitstatus == 1 && out == ''
490496
return ''

0 commit comments

Comments
 (0)