3 class GitExecuteError < StandardError
15 arr_opts = ['--pretty=oneline']
16 arr_opts << "-#{opts[:count]}" if opts[:count]
17 arr_opts << "--since=\"#{opts[:since]}\"" if opts[:since].is_a? String
18 arr_opts << "#{opts[:between][0]}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
19 arr_opts << opts[:file] if opts[:file].is_a? String
21 command('log', arr_opts).split("\n").map { |l| Git::Object::Commit.new(@base, l.split.first) }
25 command('rev-parse', string)
29 command('cat-file', ['-t', sha])
33 command('cat-file', ['-s', sha])
36 def object_contents(sha)
37 command('cat-file', ['-p', sha])
42 def command(cmd, opts)
43 ENV['GIT_DIR'] = @base.repo.path
44 ENV['GIT_INDEX_FILE'] = @base.index.path
45 ENV['GIT_WORK_DIR'] = @base.dir.path
46 Dir.chdir(@base.dir.path) do
47 opts = opts.to_a.join(' ')
48 #puts "git #{cmd} #{opts}"
49 out = `git #{cmd} #{opts} 2>&1`.chomp
51 raise Git::GitExecuteError.new(out)