@@ -20,156 +20,6 @@ def test_bake(self):
2020 assert_equal (
"[email protected] " ,
commit .
author .
email )
2121
2222
23- @patch_object (Git , '_call_process' )
24- def test_diff (self , git ):
25- git .return_value = fixture ('diff_p' )
26-
27- diffs = Commit .diff (self .repo , 'master' )
28-
29- assert_equal (15 , len (diffs ))
30-
31- diff = diffs [0 ]
32- assert_equal ('.gitignore' , diff .a_blob .path )
33- assert_equal ('.gitignore' , diff .b_blob .path )
34- assert_equal ('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666' , diff .a_blob .id )
35- assert_equal ('2dd02534615434d88c51307beb0f0092f21fd103' , diff .b_blob .id )
36-
37- assert_mode_644 (diff .b_blob .mode )
38-
39- assert_equal (False , diff .new_file )
40- assert_equal (False , diff .deleted_file )
41- assert_equal ("--- a/.gitignore\n +++ b/.gitignore\n @@ -1 +1,2 @@\n coverage\n +pkg" , diff .diff )
42-
43- diff = diffs [5 ]
44- assert_equal ('lib/grit/actor.rb' , diff .b_blob .path )
45- assert_equal (None , diff .a_blob )
46- assert_equal ('f733bce6b57c0e5e353206e692b0e3105c2527f4' , diff .b_blob .id )
47- assert_equal ( None , diff .a_mode )
48- assert_equal (True , diff .new_file )
49-
50- assert_true (git .called )
51- assert_equal (git .call_args , (('diff' , '-M' , 'master' ), {'full_index' : True }))
52-
53- @patch_object (Git , '_call_process' )
54- def test_diff_with_rename (self , git ):
55- git .return_value = fixture ('diff_rename' )
56-
57- diffs = Commit .diff (self .repo , 'rename' )
58-
59- assert_equal (1 , len (diffs ))
60-
61- diff = diffs [0 ]
62- assert_true (diff .renamed )
63- assert_equal (diff .rename_from , 'AUTHORS' )
64- assert_equal (diff .rename_to , 'CONTRIBUTORS' )
65-
66- assert_true (git .called )
67- assert_equal (git .call_args , (('diff' , '-M' , 'rename' ), {'full_index' : True }))
68-
69- @patch_object (Git , '_call_process' )
70- def test_diff_with_two_commits (self , git ):
71- git .return_value = fixture ('diff_2' )
72-
73- diffs = Commit .diff (self .repo , '59ddc32' , '13d27d5' )
74-
75- assert_equal (3 , len (diffs ))
76-
77- assert_true (git .called )
78- assert_equal (git .call_args , (('diff' , '-M' , '59ddc32' , '13d27d5' ), {'full_index' : True }))
79-
80- @patch_object (Git , '_call_process' )
81- def test_diff_with_files (self , git ):
82- git .return_value = fixture ('diff_f' )
83-
84- diffs = Commit .diff (self .repo , '59ddc32' , ['lib' ])
85-
86- assert_equal (1 , len (diffs ))
87- assert_equal ('lib/grit/diff.rb' , diffs [0 ].a_blob .path )
88-
89- assert_true (git .called )
90- assert_equal (git .call_args , (('diff' , '-M' , '59ddc32' , '--' , 'lib' ), {'full_index' : True }))
91-
92- @patch_object (Git , '_call_process' )
93- def test_diff_with_two_commits_and_files (self , git ):
94- git .return_value = fixture ('diff_2f' )
95-
96- diffs = Commit .diff (self .repo , '59ddc32' , '13d27d5' , ['lib' ])
97-
98- assert_equal (1 , len (diffs ))
99- assert_equal ('lib/grit/commit.rb' , diffs [0 ].a_blob .path )
100-
101- assert_true (git .called )
102- assert_equal (git .call_args , (('diff' , '-M' , '59ddc32' , '13d27d5' , '--' , 'lib' ), {'full_index' : True }))
103-
104- @patch_object (Git , '_call_process' )
105- def test_diffs (self , git ):
106- git .return_value = fixture ('diff_p' )
107-
108- commit = Commit (self .repo , id = '91169e1f5fa4de2eaea3f176461f5dc784796769' , parents = ['038af8c329ef7c1bae4568b98bd5c58510465493' ])
109- diffs = commit .diffs
110-
111- assert_equal (15 , len (diffs ))
112-
113- diff = diffs [0 ]
114- assert_equal ('.gitignore' , diff .a_blob .path )
115- assert_equal ('.gitignore' , diff .b_blob .path )
116- assert_equal ('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666' , diff .a_blob .id )
117- assert_equal ('2dd02534615434d88c51307beb0f0092f21fd103' , diff .b_blob .id )
118- assert_mode_644 (diff .b_blob .mode )
119- assert_equal (False , diff .new_file )
120- assert_equal (False , diff .deleted_file )
121- assert_equal ("--- a/.gitignore\n +++ b/.gitignore\n @@ -1 +1,2 @@\n coverage\n +pkg" , diff .diff )
122-
123- diff = diffs [5 ]
124- assert_equal ('lib/grit/actor.rb' , diff .b_blob .path )
125- assert_equal (None , diff .a_blob )
126- assert_equal ('f733bce6b57c0e5e353206e692b0e3105c2527f4' , diff .b_blob .id )
127- assert_equal (True , diff .new_file )
128-
129- assert_true (git .called )
130- assert_equal (git .call_args , (('diff' , '-M' ,
131- '038af8c329ef7c1bae4568b98bd5c58510465493' ,
132- '91169e1f5fa4de2eaea3f176461f5dc784796769' ,
133- ), {'full_index' : True }))
134-
135- def test_diffs_on_initial_import (self ):
136- commit = Commit (self .repo , '33ebe7acec14b25c5f84f35a664803fcab2f7781' )
137-
138- for diff in commit .diffs :
139- assert isinstance (diff , Diff )
140- assert isinstance (diff .a_blob , Blob ) or isinstance (diff .b_blob , Blob )
141-
142- if diff .a_mode is not None :
143- assert isinstance (diff .a_mode , int )
144- if diff .b_mode is not None :
145- isinstance (diff .b_mode , int )
146-
147- assert diff .diff is not None # can be empty
148-
149- if diff .renamed :
150- assert diff .rename_from and diff .rename_to and diff .rename_from != diff .rename_to
151- if diff .a_blob is None :
152- assert diff .new_file and isinstance (diff .new_file , bool )
153- if diff .b_blob is None :
154- assert diff .deleted_file and isinstance (diff .deleted_file , bool )
155- # END for each diff in initial import commit
156-
157- def test_diffs_on_initial_import_without_parents (self ):
158- commit = Commit (self .repo , id = '33ebe7acec14b25c5f84f35a664803fcab2f7781' )
159- diffs = commit .diffs
160- assert diffs
161-
162- def test_diffs_with_mode_only_change (self ):
163- commit = Commit (self .repo , id = 'ccde80b7a3037a004a7807a6b79916ce2a1e9729' )
164- diffs = commit .diffs
165-
166- # in case of mode-only changes, there is no blob
167- assert_equal (1 , len (diffs ))
168- assert_equal (None , diffs [0 ].a_blob )
169- assert_equal (None , diffs [0 ].b_blob )
170- assert_mode_644 (diffs [0 ].a_mode )
171- assert_mode_755 (diffs [0 ].b_mode )
172-
17323 def test_stats (self ):
17424 commit = Commit (self .repo , id = '33ebe7acec14b25c5f84f35a664803fcab2f7781' )
17525 stats = commit .stats
0 commit comments