jugyo-grit 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/API.txt +101 -0
- data/History.txt +153 -0
- data/LICENSE +22 -0
- data/PURE_TODO +35 -0
- data/README.md +242 -0
- data/Rakefile +153 -0
- data/benchmarks.rb +129 -0
- data/benchmarks.txt +21 -0
- data/examples/ex_add_commit.rb +13 -0
- data/examples/ex_index.rb +21 -0
- data/jugyo-grit.gemspec +74 -0
- data/lib/grit.rb +75 -0
- data/lib/grit/actor.rb +52 -0
- data/lib/grit/blame.rb +66 -0
- data/lib/grit/blob.rb +126 -0
- data/lib/grit/commit.rb +308 -0
- data/lib/grit/commit_stats.rb +128 -0
- data/lib/grit/config.rb +44 -0
- data/lib/grit/diff.rb +79 -0
- data/lib/grit/errors.rb +10 -0
- data/lib/grit/git-ruby.rb +259 -0
- data/lib/grit/git-ruby/commit_db.rb +52 -0
- data/lib/grit/git-ruby/git_object.rb +353 -0
- data/lib/grit/git-ruby/internal/file_window.rb +58 -0
- data/lib/grit/git-ruby/internal/loose.rb +137 -0
- data/lib/grit/git-ruby/internal/pack.rb +391 -0
- data/lib/grit/git-ruby/internal/raw_object.rb +44 -0
- data/lib/grit/git-ruby/repository.rb +775 -0
- data/lib/grit/git.rb +501 -0
- data/lib/grit/index.rb +222 -0
- data/lib/grit/lazy.rb +35 -0
- data/lib/grit/merge.rb +45 -0
- data/lib/grit/ref.rb +78 -0
- data/lib/grit/repo.rb +709 -0
- data/lib/grit/ruby1.9.rb +7 -0
- data/lib/grit/status.rb +153 -0
- data/lib/grit/submodule.rb +88 -0
- data/lib/grit/tag.rb +102 -0
- data/lib/grit/tree.rb +125 -0
- metadata +134 -0
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,153 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'rake'
         | 
| 3 | 
            +
            require 'date'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            #############################################################################
         | 
| 6 | 
            +
            #
         | 
| 7 | 
            +
            # Helper functions
         | 
| 8 | 
            +
            #
         | 
| 9 | 
            +
            #############################################################################
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            def name
         | 
| 12 | 
            +
              @name ||= "grit"
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            def gem_name
         | 
| 16 | 
            +
              @gem_name ||= "jugyo-#{name}"
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            def version
         | 
| 20 | 
            +
              line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
         | 
| 21 | 
            +
              line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            def date
         | 
| 25 | 
            +
              Date.today.to_s
         | 
| 26 | 
            +
            end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            def rubyforge_project
         | 
| 29 | 
            +
              gem_name
         | 
| 30 | 
            +
            end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            def gemspec_file
         | 
| 33 | 
            +
              "#{gem_name}.gemspec"
         | 
| 34 | 
            +
            end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            def gem_file
         | 
| 37 | 
            +
              "#{gem_name}-#{version}.gem"
         | 
| 38 | 
            +
            end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            def replace_header(head, header_name)
         | 
| 41 | 
            +
              head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
         | 
| 42 | 
            +
            end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            #############################################################################
         | 
| 45 | 
            +
            #
         | 
| 46 | 
            +
            # Standard tasks
         | 
| 47 | 
            +
            #
         | 
| 48 | 
            +
            #############################################################################
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            task :default => :test
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            require 'rake/testtask'
         | 
| 53 | 
            +
            Rake::TestTask.new(:test) do |test|
         | 
| 54 | 
            +
              test.libs << 'lib' << 'test' << '.'
         | 
| 55 | 
            +
              test.pattern = 'test/**/test_*.rb'
         | 
| 56 | 
            +
              test.verbose = true
         | 
| 57 | 
            +
            end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            desc "Generate RCov test coverage and open in your browser"
         | 
| 60 | 
            +
            task :coverage do
         | 
| 61 | 
            +
              require 'rcov'
         | 
| 62 | 
            +
              sh "rm -fr coverage"
         | 
| 63 | 
            +
              sh "rcov test/test_*.rb"
         | 
| 64 | 
            +
              sh "open coverage/index.html"
         | 
| 65 | 
            +
            end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            require 'rake/rdoctask'
         | 
| 68 | 
            +
            Rake::RDocTask.new do |rdoc|
         | 
| 69 | 
            +
              rdoc.rdoc_dir = 'rdoc'
         | 
| 70 | 
            +
              rdoc.title = "#{name} #{version}"
         | 
| 71 | 
            +
              rdoc.rdoc_files.include('README*')
         | 
| 72 | 
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         | 
| 73 | 
            +
            end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            desc "Open an irb session preloaded with this library"
         | 
| 76 | 
            +
            task :console do
         | 
| 77 | 
            +
              sh "irb -rubygems -r ./lib/#{name}.rb"
         | 
| 78 | 
            +
            end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            #############################################################################
         | 
| 81 | 
            +
            #
         | 
| 82 | 
            +
            # Custom tasks (add your own tasks here)
         | 
| 83 | 
            +
            #
         | 
| 84 | 
            +
            #############################################################################
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            desc "Upload site to Rubyforge"
         | 
| 87 | 
            +
            task :site do
         | 
| 88 | 
            +
              sh "scp -r doc/* mojombo@grit.rubyforge.org:/var/www/gforge-projects/grit"
         | 
| 89 | 
            +
            end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
            #############################################################################
         | 
| 92 | 
            +
            #
         | 
| 93 | 
            +
            # Packaging tasks
         | 
| 94 | 
            +
            #
         | 
| 95 | 
            +
            #############################################################################
         | 
| 96 | 
            +
             | 
| 97 | 
            +
            task :release => :build do
         | 
| 98 | 
            +
              unless `git branch` =~ /^\* master$/
         | 
| 99 | 
            +
                puts "You must be on the master branch to release!"
         | 
| 100 | 
            +
                exit!
         | 
| 101 | 
            +
              end
         | 
| 102 | 
            +
              sh "git commit --allow-empty -a -m 'Release #{version}'"
         | 
| 103 | 
            +
              sh "git tag v#{version}"
         | 
| 104 | 
            +
              sh "git push origin master"
         | 
| 105 | 
            +
              sh "git push origin v#{version}"
         | 
| 106 | 
            +
              sh "gem push pkg/#{gem_name}-#{version}.gem"
         | 
| 107 | 
            +
            end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            task :build => :gemspec do
         | 
| 110 | 
            +
              sh "mkdir -p pkg"
         | 
| 111 | 
            +
              sh "gem build #{gemspec_file}"
         | 
| 112 | 
            +
              sh "mv #{gem_file} pkg"
         | 
| 113 | 
            +
            end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            task :gemspec => :validate do
         | 
| 116 | 
            +
              # read spec file and split out manifest section
         | 
| 117 | 
            +
              spec = File.read(gemspec_file)
         | 
| 118 | 
            +
              head, manifest, tail = spec.split("  # = MANIFEST =\n")
         | 
| 119 | 
            +
             | 
| 120 | 
            +
              # replace name version and date
         | 
| 121 | 
            +
              replace_header(head, :gem_name)
         | 
| 122 | 
            +
              replace_header(head, :version)
         | 
| 123 | 
            +
              replace_header(head, :date)
         | 
| 124 | 
            +
              #comment this out if your rubyforge_project has a different name
         | 
| 125 | 
            +
              replace_header(head, :rubyforge_project)
         | 
| 126 | 
            +
             | 
| 127 | 
            +
              # determine file list from git ls-files
         | 
| 128 | 
            +
              files = `git ls-files`.
         | 
| 129 | 
            +
                split("\n").
         | 
| 130 | 
            +
                sort.
         | 
| 131 | 
            +
                reject { |file| file =~ /^\./ }.
         | 
| 132 | 
            +
                reject { |file| file =~ /^(rdoc|pkg|test)/ }.
         | 
| 133 | 
            +
                map { |file| "    #{file}" }.
         | 
| 134 | 
            +
                join("\n")
         | 
| 135 | 
            +
             | 
| 136 | 
            +
              # piece file back together and write
         | 
| 137 | 
            +
              manifest = "  s.files = %w[\n#{files}\n  ]\n"
         | 
| 138 | 
            +
              spec = [head, manifest, tail].join("  # = MANIFEST =\n")
         | 
| 139 | 
            +
              File.open(gemspec_file, 'w') { |io| io.write(spec) }
         | 
| 140 | 
            +
              puts "Updated #{gemspec_file}"
         | 
| 141 | 
            +
            end
         | 
| 142 | 
            +
             | 
| 143 | 
            +
            task :validate do
         | 
| 144 | 
            +
              libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
         | 
| 145 | 
            +
              unless libfiles.empty?
         | 
| 146 | 
            +
                puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
         | 
| 147 | 
            +
                exit!
         | 
| 148 | 
            +
              end
         | 
| 149 | 
            +
              unless Dir['VERSION*'].empty?
         | 
| 150 | 
            +
                puts "A `VERSION` file at root level violates Gem best practices."
         | 
| 151 | 
            +
                exit!
         | 
| 152 | 
            +
              end
         | 
| 153 | 
            +
            end
         | 
    
        data/benchmarks.rb
    ADDED
    
    | @@ -0,0 +1,129 @@ | |
| 1 | 
            +
            require 'fileutils'
         | 
| 2 | 
            +
            require 'benchmark'
         | 
| 3 | 
            +
            require 'rubygems'
         | 
| 4 | 
            +
            require 'ruby-prof'
         | 
| 5 | 
            +
            require 'memcache'
         | 
| 6 | 
            +
            require 'pp'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
             | 
| 9 | 
            +
            #require 'grit'
         | 
| 10 | 
            +
            require 'lib/grit'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            def main
         | 
| 13 | 
            +
              @wbare = File.expand_path(File.join('test', 'dot_git'))
         | 
| 14 | 
            +
              
         | 
| 15 | 
            +
              in_temp_dir do
         | 
| 16 | 
            +
                #result = RubyProf.profile do
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  git = Grit::Repo.new('.')
         | 
| 19 | 
            +
                  puts Grit::VERSION
         | 
| 20 | 
            +
                  
         | 
| 21 | 
            +
                  Grit::GitRuby.use_commit_db = true
         | 
| 22 | 
            +
                  #Grit::GitRuby.cache_client = MemCache.new 'localhost:11211', :namespace => 'grit'
         | 
| 23 | 
            +
                  #Grit.debug = true
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
                  #pp Grit::GitRuby.cache_client.stats 
         | 
| 26 | 
            +
                
         | 
| 27 | 
            +
                  commit1 = '5e3ee1198672257164ce3fe31dea3e40848e68d5'
         | 
| 28 | 
            +
                  commit2 = 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a'
         | 
| 29 | 
            +
                
         | 
| 30 | 
            +
                  Benchmark.bm(8) do |x|
         | 
| 31 | 
            +
                        
         | 
| 32 | 
            +
                    run_code(x, 'packobj') do
         | 
| 33 | 
            +
                      @commit = git.commit('5e3ee1198672257164ce3fe31dea3e40848e68d5')
         | 
| 34 | 
            +
                      @tree = git.tree('cd7422af5a2e0fff3e94d6fb1a8fff03b2841881')
         | 
| 35 | 
            +
                      @blob = git.blob('4232d073306f01cf0b895864e5a5cfad7dd76fce')
         | 
| 36 | 
            +
                      @commit.parents[0].parents[0].parents[0]
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    run_code(x, 'commits 1') do
         | 
| 40 | 
            +
                      git.commits.size
         | 
| 41 | 
            +
                    end
         | 
| 42 | 
            +
                          
         | 
| 43 | 
            +
                    run_code(x, 'commits 2') do
         | 
| 44 | 
            +
                      log = git.commits('master', 15)
         | 
| 45 | 
            +
                      log.size
         | 
| 46 | 
            +
                      log.size
         | 
| 47 | 
            +
                      log.first
         | 
| 48 | 
            +
                      git.commits('testing').map { |c| c.message }
         | 
| 49 | 
            +
                    end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                    run_code(x, 'big revlist') do
         | 
| 52 | 
            +
                      c = git.commits('master', 200)
         | 
| 53 | 
            +
                    end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                    run_code(x, 'log') do
         | 
| 56 | 
            +
                      log = git.log('master')
         | 
| 57 | 
            +
                      log.size
         | 
| 58 | 
            +
                      log.size
         | 
| 59 | 
            +
                      log.first
         | 
| 60 | 
            +
                    end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                    run_code(x, 'diff') do
         | 
| 63 | 
            +
                      c = git.diff(commit1, commit2)
         | 
| 64 | 
            +
                    end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                    run_code(x, 'commit-diff') do
         | 
| 67 | 
            +
                      c = git.commit_diff(commit1)
         | 
| 68 | 
            +
                    end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                    run_code(x, 'heads') do
         | 
| 71 | 
            +
                      c = git.heads.collect { |b| b.commit.id }
         | 
| 72 | 
            +
                    end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                   # run_code(x, 'config', 100) do
         | 
| 75 | 
            +
                   #   c = git.config['user.name']
         | 
| 76 | 
            +
                   #   c = git.config['user.email']
         | 
| 77 | 
            +
                   # end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                    #run_code(x, 'commit count') do
         | 
| 80 | 
            +
                    #  c = git.commit_count('testing')
         | 
| 81 | 
            +
                    #end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
             | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
                #end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                #printer = RubyProf::FlatPrinter.new(result)
         | 
| 88 | 
            +
                #printer.print(STDOUT, 0)
         | 
| 89 | 
            +
                
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
             | 
| 93 | 
            +
            end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
             | 
| 96 | 
            +
            def run_code(x, name, times = 30)
         | 
| 97 | 
            +
                x.report(name.ljust(12)) do
         | 
| 98 | 
            +
                  for i in 1..times do
         | 
| 99 | 
            +
                    yield i
         | 
| 100 | 
            +
                  end
         | 
| 101 | 
            +
                end
         | 
| 102 | 
            +
              
         | 
| 103 | 
            +
              #end
         | 
| 104 | 
            +
              
         | 
| 105 | 
            +
              # Print a graph profile to text
         | 
| 106 | 
            +
            end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            def new_file(name, contents)
         | 
| 109 | 
            +
              File.open(name, 'w') do |f|
         | 
| 110 | 
            +
                f.puts contents
         | 
| 111 | 
            +
              end
         | 
| 112 | 
            +
            end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
             | 
| 115 | 
            +
            def in_temp_dir(remove_after = true)
         | 
| 116 | 
            +
              filename = 'git_test' + Time.now.to_i.to_s + rand(300).to_s.rjust(3, '0')
         | 
| 117 | 
            +
              tmp_path = File.join("/tmp/", filename)
         | 
| 118 | 
            +
              FileUtils.mkdir(tmp_path)
         | 
| 119 | 
            +
              Dir.chdir tmp_path do
         | 
| 120 | 
            +
                FileUtils.cp_r(@wbare, File.join(tmp_path, '.git'))
         | 
| 121 | 
            +
                yield tmp_path
         | 
| 122 | 
            +
              end
         | 
| 123 | 
            +
              puts tmp_path
         | 
| 124 | 
            +
              #FileUtils.rm_r(tmp_path) if remove_after
         | 
| 125 | 
            +
            end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
            main()
         | 
| 128 | 
            +
             | 
| 129 | 
            +
            ##pp Grit::GitRuby.cache_client.stats 
         | 
    
        data/benchmarks.txt
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            Grit : 
         | 
| 2 | 
            +
                          user     system      total        real
         | 
| 3 | 
            +
            packobj       0.030000   0.270000   1.380000 (  1.507250)
         | 
| 4 | 
            +
            commits 1     0.030000   0.070000   0.390000 (  0.409931)
         | 
| 5 | 
            +
            commits 2     0.110000   0.170000   0.860000 (  0.896371)
         | 
| 6 | 
            +
            log           0.350000   0.130000   0.850000 (  0.875035)
         | 
| 7 | 
            +
            diff          0.190000   0.140000   1.940000 (  2.031911)
         | 
| 8 | 
            +
            commit-diff   0.540000   0.220000   1.390000 (  1.463839)
         | 
| 9 | 
            +
            heads         0.010000   0.070000   0.390000 (  0.413918)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
             | 
| 12 | 
            +
            Grit (with GitRuby) : 
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                          user     system      total        real
         | 
| 15 | 
            +
            packobj       0.050000   0.010000   0.060000 (  0.078318)
         | 
| 16 | 
            +
            commits 1     0.150000   0.010000   0.160000 (  0.174296)
         | 
| 17 | 
            +
            commits 2     0.440000   0.040000   0.480000 (  0.522310)
         | 
| 18 | 
            +
            log           0.490000   0.040000   0.530000 (  0.538128)
         | 
| 19 | 
            +
            diff          0.370000   0.230000   2.250000 (  2.255974)
         | 
| 20 | 
            +
            commit-diff   0.580000   0.260000   1.500000 (  1.553000)
         | 
| 21 | 
            +
            heads         0.020000   0.100000   0.430000 (  0.455464)
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require '../lib/grit'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            count = 1
         | 
| 4 | 
            +
            Dir.chdir("/Users/schacon/projects/atest") do
         | 
| 5 | 
            +
              r = Grit::Repo.new('.')
         | 
| 6 | 
            +
              while(count < 10) do
         | 
| 7 | 
            +
                fname = Time.now.to_i.to_s + count.to_s
         | 
| 8 | 
            +
                File.open(fname, 'w') { |f| f.write('hellor ' + fname) }
         | 
| 9 | 
            +
                r.add(fname)
         | 
| 10 | 
            +
                count += 1
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
              r.commit_index('my commit')
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            require '../lib/grit'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            count = 1
         | 
| 4 | 
            +
            Dir.chdir("/Users/schacon/projects/atest") do
         | 
| 5 | 
            +
              r = Grit::Repo.new('.')
         | 
| 6 | 
            +
              i = r.index
         | 
| 7 | 
            +
              while(count < 10) do
         | 
| 8 | 
            +
                fname = Time.now.to_i.to_s + count.to_s
         | 
| 9 | 
            +
                i.add(fname, 'hello ' + fname)
         | 
| 10 | 
            +
                count += 1
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
              count = 5
         | 
| 13 | 
            +
              while(count < 10) do
         | 
| 14 | 
            +
                puts "HELLO"
         | 
| 15 | 
            +
                fname = Time.now.to_i.to_s + count.to_s
         | 
| 16 | 
            +
                i.add('test/' + fname, 'hello ' + fname)
         | 
| 17 | 
            +
                count += 1
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              puts i.commit('my commit')
         | 
| 20 | 
            +
              puts i.inspect
         | 
| 21 | 
            +
            end
         | 
    
        data/jugyo-grit.gemspec
    ADDED
    
    | @@ -0,0 +1,74 @@ | |
| 1 | 
            +
            Gem::Specification.new do |s|
         | 
| 2 | 
            +
              s.specification_version = 2 if s.respond_to? :specification_version=
         | 
| 3 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 4 | 
            +
              s.rubygems_version = '1.3.5'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              s.name              = 'jugyo-grit'
         | 
| 7 | 
            +
              s.version           = '2.4.2'
         | 
| 8 | 
            +
              s.date              = '2011-07-06'
         | 
| 9 | 
            +
              s.rubyforge_project = 'jugyo-grit'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              s.summary     = "Ruby Git bindings."
         | 
| 12 | 
            +
              s.description = "Grit is a Ruby library for extracting information from a git repository in an object oriented manner."
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              s.authors  = ["Tom Preston-Werner", "Scott Chacon"]
         | 
| 15 | 
            +
              s.email    = 'tom@github.com'
         | 
| 16 | 
            +
              s.homepage = 'http://github.com/mojombo/grit'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              s.require_paths = %w[lib]
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              s.rdoc_options = ["--charset=UTF-8"]
         | 
| 21 | 
            +
              s.extra_rdoc_files = %w[README.md LICENSE]
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              s.add_dependency('posix-spawn', "~> 0.3.6")
         | 
| 24 | 
            +
              s.add_dependency('mime-types', "~> 1.15")
         | 
| 25 | 
            +
              s.add_dependency('diff-lcs', "~> 1.1")
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              s.add_development_dependency('mocha')
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              # = MANIFEST =
         | 
| 30 | 
            +
              s.files = %w[
         | 
| 31 | 
            +
                API.txt
         | 
| 32 | 
            +
                History.txt
         | 
| 33 | 
            +
                LICENSE
         | 
| 34 | 
            +
                PURE_TODO
         | 
| 35 | 
            +
                README.md
         | 
| 36 | 
            +
                Rakefile
         | 
| 37 | 
            +
                benchmarks.rb
         | 
| 38 | 
            +
                benchmarks.txt
         | 
| 39 | 
            +
                examples/ex_add_commit.rb
         | 
| 40 | 
            +
                examples/ex_index.rb
         | 
| 41 | 
            +
                jugyo-grit.gemspec
         | 
| 42 | 
            +
                lib/grit.rb
         | 
| 43 | 
            +
                lib/grit/actor.rb
         | 
| 44 | 
            +
                lib/grit/blame.rb
         | 
| 45 | 
            +
                lib/grit/blob.rb
         | 
| 46 | 
            +
                lib/grit/commit.rb
         | 
| 47 | 
            +
                lib/grit/commit_stats.rb
         | 
| 48 | 
            +
                lib/grit/config.rb
         | 
| 49 | 
            +
                lib/grit/diff.rb
         | 
| 50 | 
            +
                lib/grit/errors.rb
         | 
| 51 | 
            +
                lib/grit/git-ruby.rb
         | 
| 52 | 
            +
                lib/grit/git-ruby/commit_db.rb
         | 
| 53 | 
            +
                lib/grit/git-ruby/git_object.rb
         | 
| 54 | 
            +
                lib/grit/git-ruby/internal/file_window.rb
         | 
| 55 | 
            +
                lib/grit/git-ruby/internal/loose.rb
         | 
| 56 | 
            +
                lib/grit/git-ruby/internal/pack.rb
         | 
| 57 | 
            +
                lib/grit/git-ruby/internal/raw_object.rb
         | 
| 58 | 
            +
                lib/grit/git-ruby/repository.rb
         | 
| 59 | 
            +
                lib/grit/git.rb
         | 
| 60 | 
            +
                lib/grit/index.rb
         | 
| 61 | 
            +
                lib/grit/lazy.rb
         | 
| 62 | 
            +
                lib/grit/merge.rb
         | 
| 63 | 
            +
                lib/grit/ref.rb
         | 
| 64 | 
            +
                lib/grit/repo.rb
         | 
| 65 | 
            +
                lib/grit/ruby1.9.rb
         | 
| 66 | 
            +
                lib/grit/status.rb
         | 
| 67 | 
            +
                lib/grit/submodule.rb
         | 
| 68 | 
            +
                lib/grit/tag.rb
         | 
| 69 | 
            +
                lib/grit/tree.rb
         | 
| 70 | 
            +
              ]
         | 
| 71 | 
            +
              # = MANIFEST =
         | 
| 72 | 
            +
             | 
| 73 | 
            +
              s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
         | 
| 74 | 
            +
            end
         | 
    
        data/lib/grit.rb
    ADDED
    
    | @@ -0,0 +1,75 @@ | |
| 1 | 
            +
            $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # core
         | 
| 4 | 
            +
            require 'fileutils'
         | 
| 5 | 
            +
            require 'time'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # stdlib
         | 
| 8 | 
            +
            require 'timeout'
         | 
| 9 | 
            +
            require 'logger'
         | 
| 10 | 
            +
            require 'digest/sha1'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            # third party
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            begin
         | 
| 15 | 
            +
              require 'mime/types'
         | 
| 16 | 
            +
              require 'rubygems'
         | 
| 17 | 
            +
            rescue LoadError
         | 
| 18 | 
            +
              require 'rubygems'
         | 
| 19 | 
            +
              begin
         | 
| 20 | 
            +
                gem "mime-types", ">=0"
         | 
| 21 | 
            +
                require 'mime/types'
         | 
| 22 | 
            +
              rescue Gem::LoadError => e
         | 
| 23 | 
            +
                puts "WARNING: Gem LoadError: #{e.message}"
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            # ruby 1.9 compatibility
         | 
| 28 | 
            +
            require 'grit/ruby1.9'
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            # internal requires
         | 
| 31 | 
            +
            require 'grit/lazy'
         | 
| 32 | 
            +
            require 'grit/errors'
         | 
| 33 | 
            +
            require 'grit/git-ruby'
         | 
| 34 | 
            +
            require 'grit/git' unless defined? Grit::Git
         | 
| 35 | 
            +
            require 'grit/ref'
         | 
| 36 | 
            +
            require 'grit/tag'
         | 
| 37 | 
            +
            require 'grit/commit'
         | 
| 38 | 
            +
            require 'grit/commit_stats'
         | 
| 39 | 
            +
            require 'grit/tree'
         | 
| 40 | 
            +
            require 'grit/blob'
         | 
| 41 | 
            +
            require 'grit/actor'
         | 
| 42 | 
            +
            require 'grit/diff'
         | 
| 43 | 
            +
            require 'grit/config'
         | 
| 44 | 
            +
            require 'grit/repo'
         | 
| 45 | 
            +
            require 'grit/index'
         | 
| 46 | 
            +
            require 'grit/status'
         | 
| 47 | 
            +
            require 'grit/submodule'
         | 
| 48 | 
            +
            require 'grit/blame'
         | 
| 49 | 
            +
            require 'grit/merge'
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            module Grit
         | 
| 52 | 
            +
              VERSION = '2.4.2'
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              class << self
         | 
| 55 | 
            +
                # Set +debug+ to true to log all git calls and responses
         | 
| 56 | 
            +
                attr_accessor :debug
         | 
| 57 | 
            +
                attr_accessor :use_git_ruby
         | 
| 58 | 
            +
                attr_accessor :no_quote
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                # The standard +logger+ for debugging git calls - this defaults to a plain STDOUT logger
         | 
| 61 | 
            +
                attr_accessor :logger
         | 
| 62 | 
            +
                def log(str)
         | 
| 63 | 
            +
                  logger.debug { str }
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
              self.debug = false
         | 
| 67 | 
            +
              self.use_git_ruby = true
         | 
| 68 | 
            +
              self.no_quote = false
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              @logger ||= ::Logger.new(STDOUT)
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              def self.version
         | 
| 73 | 
            +
                VERSION
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
            end
         |