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_lines('log', arr_opts).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]).to_i
36 def object_contents(sha)
37 command('cat-file', ['-p', sha])
41 command_lines('branch', '-a').map { |l| Git::Branch.new(@base, l) }
46 def command_lines(cmd, opts)
47 command(cmd, opts).split("\n")
50 def command(cmd, opts)
51 ENV['GIT_DIR'] = @base.repo.path
52 ENV['GIT_INDEX_FILE'] = @base.index.path
53 ENV['GIT_WORK_DIR'] = @base.dir.path
54 Dir.chdir(@base.dir.path) do
55 opts = opts.to_a.join(' ')
56 #puts "git #{cmd} #{opts}"
57 out = `git #{cmd} #{opts} 2>&1`.chomp
59 raise Git::GitExecuteError.new(out)