summaryrefslogtreecommitdiffstats
path: root/tests/units/test_raw_internals.rb
blob: 03a7916db7e31d3f4f2d7820987da17aaae9d7d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env ruby
require 'logger'
require File.dirname(__FILE__) + '/../test_helper'

class TestRawInternals < Test::Unit::TestCase
  
  def setup
    set_file_paths
  end
  
  def test_raw_log
    with_temp_bare do |g|
      t_log(g)
    end
  end
  
  def test_packed_log
    with_temp_bare do |g|
      g.repack
      t_log(g)
    end
  end
  
  def test_commit_object
    g = Git.bare(@wbare, :log => Logger.new(STDOUT))
    
    c = g.gcommit("v2.5")
    assert_equal('test', c.message)
  end
  
  def test_lstree
    g = Git.bare(@wbare)
    c = g.object("v2.5").gtree
    sha = c.sha
    
    repo = Git::Raw::Repository.new(@wbare)
    puts repo.object(sha).inspect
  end
  
  def t_log(g)
    c = g.object("v2.5")
    sha = c.sha
    
    repo = Git::Raw::Repository.new(g.repo.path)
    raw_out = repo.log(sha)
    
    assert_equal('commit 546bec6f8872efa41d5d97a369f669165ecda0de', raw_out.split("\n").first)
    assert_equal('546bec6f8872efa41d5d97a369f669165ecda0de', c.log(30).first.sha)
  end
  
  

  
end