2007-10-25 20:23:01 +04:00
|
|
|
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
2007-10-10 10:18:20 +04:00
|
|
|
|
|
|
|
# core
|
2008-01-20 00:35:57 +03:00
|
|
|
require 'fileutils'
|
2008-03-26 07:32:29 +03:00
|
|
|
require 'time'
|
2007-10-10 10:18:20 +04:00
|
|
|
|
|
|
|
# stdlib
|
2008-03-31 03:31:20 +04:00
|
|
|
require 'timeout'
|
2008-06-28 06:07:29 +04:00
|
|
|
require 'logger'
|
2008-11-07 21:35:54 +03:00
|
|
|
require 'digest/sha1'
|
2008-10-24 02:12:43 +04:00
|
|
|
|
2008-01-07 05:59:51 +03:00
|
|
|
# third party
|
2010-10-08 05:14:39 +04:00
|
|
|
|
2009-08-28 02:55:23 +04:00
|
|
|
begin
|
|
|
|
require 'mime/types'
|
2010-10-08 05:14:39 +04:00
|
|
|
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
|
2009-08-28 02:55:23 +04:00
|
|
|
end
|
2008-01-07 05:59:51 +03:00
|
|
|
|
Define String#getord(offset) for accessing a single byte at a String offset
Strings have changed significantly in Ruby 1.9. The main issues related
to Grit are encodings, and the [] method. The GitRuby implementation
currently uses code such as "buf[offset]" to access a byte (1 uint8_t byte in C)
of data. It would be nice to just use String#getbyte(offset), but this method is not
sensitive to the string encoding. The default encoding for Ruby strings
is UTF-8, and I can't figure out how to make sure that all of the encodings
are correct such that String#getbyte will return the right value.
In Ruby 1.8, String[offset] returns the integer code of the character at offset.
In Ruby 1.9, String[offset] returns the actual character at offset. To get the integer
value, we need to call String#ord, which returns the int code of the first char.
Thus, to get Ruby 1.8 behavior in Ruby 1.9, we would need to call String[offset].ord.
My solution for now is just to define a getord(offset) method in a version dependent
manner, and use this in place of String[offset]. It's somewhat hackish, but
I can't think of a better solution right now.
2009-02-06 02:40:14 +03:00
|
|
|
# ruby 1.9 compatibility
|
|
|
|
require 'grit/ruby1.9'
|
|
|
|
|
2007-10-10 10:18:20 +04:00
|
|
|
# internal requires
|
2010-12-19 14:55:47 +03:00
|
|
|
require 'grit/process'
|
2007-10-13 13:20:41 +04:00
|
|
|
require 'grit/lazy'
|
2007-10-10 11:06:12 +04:00
|
|
|
require 'grit/errors'
|
2008-04-19 03:27:08 +04:00
|
|
|
require 'grit/git-ruby'
|
2009-05-14 02:54:49 +04:00
|
|
|
require 'grit/git' unless defined? Grit::Git
|
2008-04-25 00:39:08 +04:00
|
|
|
require 'grit/ref'
|
2009-02-14 02:13:36 +03:00
|
|
|
require 'grit/tag'
|
2007-10-10 11:50:39 +04:00
|
|
|
require 'grit/commit'
|
2008-06-20 02:36:35 +04:00
|
|
|
require 'grit/commit_stats'
|
2007-10-13 14:37:12 +04:00
|
|
|
require 'grit/tree'
|
2007-10-14 03:10:05 +04:00
|
|
|
require 'grit/blob'
|
2007-10-25 08:29:16 +04:00
|
|
|
require 'grit/actor'
|
2007-10-29 10:16:38 +03:00
|
|
|
require 'grit/diff'
|
2008-03-07 03:22:10 +03:00
|
|
|
require 'grit/config'
|
2007-10-10 20:05:03 +04:00
|
|
|
require 'grit/repo'
|
2008-05-01 09:03:18 +04:00
|
|
|
require 'grit/index'
|
2008-05-29 22:33:09 +04:00
|
|
|
require 'grit/status'
|
2008-08-29 12:18:03 +04:00
|
|
|
require 'grit/submodule'
|
2008-12-12 01:58:32 +03:00
|
|
|
require 'grit/blame'
|
|
|
|
require 'grit/merge'
|
2007-10-10 10:18:20 +04:00
|
|
|
|
2010-12-21 13:42:36 +03:00
|
|
|
# platform specific requires
|
|
|
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
|
|
|
require 'grit/jruby'
|
|
|
|
end
|
|
|
|
|
2007-10-10 20:05:03 +04:00
|
|
|
module Grit
|
2010-09-30 00:46:45 +04:00
|
|
|
VERSION = '2.3.0'
|
2010-08-04 01:57:35 +04:00
|
|
|
|
2007-10-20 10:08:03 +04:00
|
|
|
class << self
|
2008-06-28 06:22:41 +04:00
|
|
|
# Set +debug+ to true to log all git calls and responses
|
2007-10-20 10:08:03 +04:00
|
|
|
attr_accessor :debug
|
2008-05-29 21:29:59 +04:00
|
|
|
attr_accessor :use_git_ruby
|
2010-05-27 08:52:13 +04:00
|
|
|
attr_accessor :no_quote
|
|
|
|
|
2008-06-28 06:22:41 +04:00
|
|
|
# The standard +logger+ for debugging git calls - this defaults to a plain STDOUT logger
|
2008-06-28 06:07:29 +04:00
|
|
|
attr_accessor :logger
|
|
|
|
def log(str)
|
|
|
|
logger.debug { str }
|
|
|
|
end
|
2007-10-20 10:08:03 +04:00
|
|
|
end
|
|
|
|
self.debug = false
|
2008-05-29 21:29:59 +04:00
|
|
|
self.use_git_ruby = true
|
2010-05-27 08:52:13 +04:00
|
|
|
self.no_quote = false
|
2009-02-14 02:13:36 +03:00
|
|
|
|
2008-06-28 06:07:29 +04:00
|
|
|
@logger ||= ::Logger.new(STDOUT)
|
2009-02-14 02:13:36 +03:00
|
|
|
|
2009-02-11 09:53:41 +03:00
|
|
|
def self.version
|
2010-08-04 01:57:35 +04:00
|
|
|
VERSION
|
2009-02-11 09:53:41 +03:00
|
|
|
end
|
2007-10-29 15:20:10 +03:00
|
|
|
end
|