debian/0000755000000000000000000000000012132733747007177 5ustar debian/rules0000755000000000000000000000100312132733747010251 0ustar #!/usr/bin/make -f #export DH_VERBOSE=1 # # Uncomment to ignore all test failures (but the tests will run anyway) #export DH_RUBY_IGNORE_TESTS=all # # Uncomment to ignore some test failures (but the tests will run anyway). # Valid values: #export DH_RUBY_IGNORE_TESTS=ruby1.8 ruby1.9.1 require-rubygems # # If you need to specify the .gemspec (eg there is more than one) #export DH_RUBY_GEMSPEC=gem.gemspec %: dh $@ --buildsystem=ruby --with ruby override_dh_installchangelogs: dh_installchangelogs History.txt debian/compat0000644000000000000000000000000212132733747010375 0ustar 7 debian/copyright0000644000000000000000000000246712132733747011143 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: grit Source: http://grit.rubyforge.org/ Files: * Copyright: 2007-2009 Tom Preston-Werner License: Expat Files: debian/* Copyright: 2013 Ondřej Surý License: Expat License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. . THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. debian/source/0000755000000000000000000000000012132733747010477 5ustar debian/source/format0000644000000000000000000000001412132733747011705 0ustar 3.0 (quilt) debian/watch0000644000000000000000000000013512132733747010227 0ustar version=3 http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/grit .*/grit-(.*).tar.gz debian/ruby-grit.docs0000644000000000000000000000002212132733747011767 0ustar README.md API.txt debian/patches/0000755000000000000000000000000012132733747010626 5ustar debian/patches/series0000644000000000000000000000013512132733747012042 0ustar mojombo-grit-HEAD-typos.patch mojombo-grit-tempfile.patch gitlab.patch remove-rubygems.patch debian/patches/remove-rubygems.patch0000644000000000000000000000171012132733747014776 0ustar --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,3 @@ -require 'rubygems' require 'rake' require 'date' --- a/benchmarks.rb +++ b/benchmarks.rb @@ -1,6 +1,5 @@ require 'fileutils' require 'benchmark' -require 'rubygems' require 'ruby-prof' require 'memcache' require 'pp' --- a/lib/grit.rb +++ b/lib/grit.rb @@ -11,18 +11,7 @@ require 'digest/sha1' # third party -begin - require 'mime/types' - require 'rubygems' -rescue LoadError - require 'rubygems' - begin - gem "mime-types", ">=0" - require 'mime/types' - rescue Gem::LoadError => e - puts "WARNING: Gem LoadError: #{e.message}" - end -end +require 'mime/types' # ruby 1.9 compatibility require 'grit/ruby1.9' --- a/lib/grit/git-ruby/repository.rb +++ b/lib/grit/git-ruby/repository.rb @@ -13,7 +13,6 @@ require 'grit/git-ruby/internal/pack' require 'grit/git-ruby/internal/loose' require 'grit/git-ruby/git_object' -require 'rubygems' require 'diff/lcs' require 'diff/lcs/hunk' debian/patches/mojombo-grit-HEAD-typos.patch0000644000000000000000000000156412132733747016135 0ustar --- a/lib/grit/git-ruby.rb +++ b/lib/grit/git-ruby.rb @@ -3,7 +3,7 @@ require 'grit/git-ruby/repository' module Grit # the functions in this module intercept the calls to git binary - # made buy the grit objects and attempts to run them in pure ruby + # made by the grit objects and attempts to run them in pure ruby # if it will be faster, or if the git binary is not available (!!TODO!!) module GitRuby --- a/lib/grit/repo.rb +++ b/lib/grit/repo.rb @@ -399,7 +399,7 @@ module Grit # The Commits objects that are newer than the specified date. # Commits are returned in chronological order. # +start+ is the branch/commit name (default 'master') - # +since+ is a string represeting a date/time + # +since+ is a string representing a date/time # +extra_options+ is a hash of extra options # # Returns Grit::Commit[] (baked) debian/patches/gitlab.patch0000644000000000000000000002060112132733747013110 0ustar --- a/Rakefile +++ b/Rakefile @@ -60,7 +60,7 @@ task :coverage do sh "open coverage/index.html" end -require 'rake/rdoctask' +require 'rdoc/task' Rake::RDocTask.new do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = "#{name} #{version}" --- a/lib/grit/commit.rb +++ b/lib/grit/commit.rb @@ -137,11 +137,18 @@ module Grit # - it broke when 'encoding' was introduced - not sure what else might show up # def self.list_from_string(repo, text) - lines = text.split("\n") + text_gpgless = text.gsub(/gpgsig -----BEGIN PGP SIGNATURE-----[\n\r](.*[\n\r])*? -----END PGP SIGNATURE-----[\n\r]/, "") + lines = text_gpgless.split("\n") commits = [] while !lines.empty? + # GITLAB patch + # Skip all garbage unless we get real commit + while !lines.empty? && lines.first !~ /^commit [a-zA-Z0-9]*$/ + lines.shift + end + id = lines.shift.split.last tree = lines.shift.split.last @@ -159,6 +166,10 @@ module Grit # not doing anything with this yet, but it's sometimes there encoding = lines.shift.split.last if lines.first =~ /^encoding/ + # GITLAB patch + # Skip Signature and other raw data + lines.shift while lines.first =~ /^ / + lines.shift message_lines = [] @@ -203,8 +214,8 @@ module Grit diff = @repo.git.show({:full_index => true, :pretty => 'raw'}, @id) end - if diff =~ /diff --git a/ - diff = diff.sub(/.+?(diff --git a)/m, '\1') + if diff =~ /diff --git "?a/ + diff = diff.sub(/.+?(diff --git "?a)/m, '\1') else diff = '' end --- a/lib/grit/diff.rb +++ b/lib/grit/diff.rb @@ -29,7 +29,7 @@ module Grit diffs = [] while !lines.empty? - m, a_path, b_path = *lines.shift.match(%r{^diff --git a/(.+?) b/(.+)$}) + m, a_path, b_path = *lines.shift.match(%r{^diff --git "?a\/(.+?)(? id) - self.new(name, commit) + self.new(name, repo, id) end end @@ -27,22 +36,34 @@ module Grit end attr_reader :name - attr_reader :commit # Instantiate a new Head # +name+ is the name of the head # +commit+ is the Commit that the head points to # # Returns Grit::Head (baked) - def initialize(name, commit) + def initialize(name, repo, commit_id) @name = name - @commit = commit + @commit_id = commit_id + @repo_ref = repo + @commit = nil + end + + def commit + @commit ||= get_commit end # Pretty object inspection def inspect %Q{#<#{self.class.name} "#{@name}">} end + + protected + + def get_commit + Commit.create(@repo_ref, :id => @commit_id) + end + end # Ref # A Head is a named reference to a Commit. Every Head instance contains a name @@ -64,8 +85,7 @@ module Grit head = repo.git.fs_read('HEAD').chomp if /ref: refs\/heads\/(.*)/.match(head) id = repo.git.rev_parse(options, 'HEAD') - commit = Commit.create(repo, :id => id) - self.new($1, commit) + self.new($1, repo, id) end end --- a/lib/grit/repo.rb +++ b/lib/grit/repo.rb @@ -213,7 +213,12 @@ module Grit Head.find_all(self) end + def head_count + Head.count_all(self) + end + alias_method :branches, :heads + alias_method :branch_count, :head_count def get_head(head_name) heads.find { |h| h.name == head_name } @@ -278,6 +283,10 @@ module Grit Tag.find_all(self) end + def tag_count + Tag.count_all(self) + end + # Finds the most recent annotated tag name that is reachable from a commit. # # @repo.recent_tag_name('master') @@ -310,6 +319,10 @@ module Grit Remote.find_all(self) end + def remote_count + Remote.count_all(self) + end + def remote_list self.git.list_remotes end --- a/lib/grit/ruby1.9.rb +++ b/lib/grit/ruby1.9.rb @@ -1,7 +1,15 @@ class String - if ((defined? RUBY_VERSION) && (RUBY_VERSION[0..2] == "1.9")) + if self.method_defined?(:ord) def getord(offset); self[offset].ord; end else alias :getord :[] end + + unless self.method_defined?(:b) + if self.method_defined?(:force_encoding) + def b; self.dup.force_encoding(Encoding::ASCII_8BIT); end + else + def b; self.dup; end + end + end end \ No newline at end of file --- a/lib/grit/tag.rb +++ b/lib/grit/tag.rb @@ -7,17 +7,6 @@ module Grit lazy_reader :tagger lazy_reader :tag_date - def self.find_all(repo, options = {}) - refs = repo.git.refs(options, prefix) - refs.split("\n").map do |ref| - name, id = *ref.split(' ') - sha = repo.git.commit_from_sha(id) - raise "Unknown object type." if sha == '' - commit = Commit.create(repo, :id => sha) - new(name, commit) - end - end - # Writes a new tag object from a hash # +repo+ is a Grit repo # +hash+ is the hash of tag values @@ -97,6 +86,12 @@ module Grit end self end + + def get_commit + sha = @repo_ref.git.commit_from_sha(@commit_id) + raise "Unknown object type." if sha == '' + Commit.create(@repo_ref, :id => sha) + end end end debian/patches/mojombo-grit-tempfile.patch0000644000000000000000000000431212132733747016057 0ustar --- a/lib/grit/git-ruby.rb +++ b/lib/grit/git-ruby.rb @@ -75,7 +75,10 @@ module Grit def rev_parse(options, string) raise RuntimeError, "invalid string: #{string.inspect}" unless string.is_a?(String) - if string =~ /\.\./ + # Split ranges, but don't split when specifying a ref:path. + # Don't split HEAD:some/path/in/repo..txt + # Do split sha1..sha2 + if string !~ /:/ && string =~ /\.\./ (sha1, sha2) = string.split('..') return [rev_parse({}, sha1), rev_parse({}, sha2)] end --- a/lib/grit/git-ruby/internal/loose.rb +++ b/lib/grit/git-ruby/internal/loose.rb @@ -12,6 +12,7 @@ require 'zlib' require 'digest/sha1' require 'grit/git-ruby/internal/raw_object' +require 'tempfile' module Grit module GitRuby @@ -60,6 +61,29 @@ module Grit return RawObject.new(type, content) end + # write an object to a temporary file, then atomically rename it + # into place; this ensures readers never see a half-written file + def safe_write(path, content) + f = + if RUBY_VERSION >= '1.9' + Tempfile.open("tmp_obj_", File.dirname(path), :opt => "wb") + else + Tempfile.open("tmp_obj_", File.dirname(path)) + end + begin + f.write content + f.fsync + File.link(f.path, path) + rescue Errno::EEXIST + # The path already exists; we raced with another process, + # but it's OK, because by definition the content is the + # same. So we can just ignore the error. + ensure + f.unlink + f.close + end + end + # currently, I'm using the legacy format because it's easier to do # this function takes content and a type and writes out the loose object and returns a sha def put_raw_object(content, type) @@ -76,9 +100,7 @@ module Grit content = Zlib::Deflate.deflate(store) FileUtils.mkdir_p(@directory+'/'+sha1[0...2]) - File.open(path, 'wb') do |f| - f.write content - end + safe_write(path, content) end return sha1 end debian/ruby-grit.examples0000644000000000000000000000001312132733747012655 0ustar examples/* debian/control0000644000000000000000000000266612132733747010614 0ustar Source: ruby-grit Section: ruby Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: Ondřej Surý DM-Upload-Allowed: yes Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.3.0~), ruby-posix-spawn (>= 0.3.6), ruby-mime-types (>= 1.15), ruby-diff-lcs (>= 1.1), ruby-mocha Standards-Version: 3.9.3 Vcs-Git: git://git.debian.org/pkg-ruby-extras/ruby-grit.git Vcs-Browser: http://git.debian.org/?p=pkg-ruby-extras/ruby-grit.git;a=summary Homepage: http://github.com/mojombo/grit XS-Ruby-Versions: all Package: ruby-grit Architecture: all XB-Ruby-Versions: ${ruby:Versions} Depends: ${misc:Depends}, ruby | ruby-interpreter, ruby-posix-spawn (>= 0.3.6), ruby-mime-types (>= 1.15), ruby-diff-lcs (>= 1.1) Description: Ruby Git bindings Grit gives you object oriented read/write access to Git repositories via Ruby. The main goals are stability and performance. To this end, some of the interactions with Git repositories are done by shelling out to the system's git command, and other interactions are done with pure Ruby reimplementations of core Git functionality. This choice, however, is transparent to end users, and you need not know which method is being used. . This software was developed to power GitHub, and should be considered production ready. . This version has been patched for use with GITLAB. debian/changelog0000644000000000000000000000023112132733747011045 0ustar ruby-grit (2.5.0-1) unstable; urgency=low * Initial release (Closes: #705448) -- Ondřej Surý Mon, 15 Apr 2013 09:24:29 +0200