Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7f5274

Browse files
committed
Added info about 0.1.7 release changes
reverted 19533ff as it would introduce an API change
1 parent 047b210 commit a7f5274

File tree

3 files changed

+51
-77
lines changed

3 files changed

+51
-77
lines changed

CHANGES

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ CHANGES
44

55
0.1.7
66
=======
7+
This is a bugfix release and the last of its kind in 0.1.X, as 0.2.X will receive
8+
a major redesign that will change the API.
9+
10+
Bugfixes
11+
--------
12+
* Paths in Tree objects can now handle whitespace
13+
* Blob.blame was returning incorrect results which has been fixed.
14+
715
General
816
-------
9-
* See changes in Diff class as your client code needs adjustments to work with it
10-
11-
Diff
12-
----
13-
* Members a a_commit and b_commit renamed to a_blob and b_blob - they are populated
14-
with Blob objects if possible
15-
* Members a_path and b_path removed as this information is kept in the blobs
17+
* The test suite now supports Mock 0.5 and above. The transition between Mock 0.4
18+
0.5 changed the API which required adjustments.
19+
* Many small enhancements done to the method documentation
1620

1721

1822
0.1.6

lib/git/diff.py

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,28 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
import re
8-
import blob
8+
import commit
99

1010
class Diff(object):
1111
"""
1212
A Diff contains diff information between two commits.
13-
14-
It contains two sides a and b of the diff, members are prefixed with
15-
"a" and "b" respectively to inidcate that.
16-
17-
Diffs keep information about the changed blob objects, the file mode, renames,
18-
deletions and new files.
19-
20-
There are a few cases where None has to be expected as member variable value:
21-
22-
``New File``::
23-
24-
a_mode is None
25-
a_blob is None
26-
27-
``Deleted File``::
28-
29-
b_mode is None
30-
b_blob is NOne
3113
"""
3214

33-
def __init__(self, repo, a_path, b_path, a_blob, b_blob, a_mode,
15+
def __init__(self, repo, a_path, b_path, a_commit, b_commit, a_mode,
3416
b_mode, new_file, deleted_file, rename_from,
3517
rename_to, diff):
3618
self.repo = repo
19+
self.a_path = a_path
20+
self.b_path = b_path
3721

38-
if not a_blob or re.search(r'^0{40}$', a_blob):
39-
self.a_blob = None
22+
if not a_commit or re.search(r'^0{40}$', a_commit):
23+
self.a_commit = None
4024
else:
41-
self.a_blob = blob.Blob(repo, id=a_blob, mode=a_mode, name=a_path)
42-
if not b_blob or re.search(r'^0{40}$', b_blob):
43-
self.b_blob = None
25+
self.a_commit = commit.Commit(repo, id=a_commit)
26+
if not b_commit or re.search(r'^0{40}$', b_commit):
27+
self.b_commit = None
4428
else:
45-
self.b_blob = blob.Blob(repo, id=b_blob, mode=b_mode, name=b_path)
29+
self.b_commit = commit.Commit(repo, id=b_commit)
4630

4731
self.a_mode = a_mode
4832
self.b_mode = b_mode
@@ -55,17 +39,6 @@ def __init__(self, repo, a_path, b_path, a_blob, b_blob, a_mode,
5539

5640
@classmethod
5741
def list_from_string(cls, repo, text):
58-
"""
59-
Create a new diff object from the given text
60-
``repo``
61-
is the repository we are operating on - it is required
62-
63-
``text``
64-
result of 'git diff' between two commits or one commit and the index
65-
66-
Returns
67-
git.Diff[]
68-
"""
6942
diffs = []
7043

7144
diff_header = re.compile(r"""
@@ -78,19 +51,19 @@ def list_from_string(cls, repo, text):
7851
^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))?
7952
(?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))?
8053
(?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))?
81-
(?:^index[ ](?P<a_blob>[0-9A-Fa-f]+)
82-
\.\.(?P<b_blob>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
54+
(?:^index[ ](?P<a_commit>[0-9A-Fa-f]+)
55+
\.\.(?P<b_commit>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
8356
""", re.VERBOSE | re.MULTILINE).match
8457

8558
for diff in ('\n' + text).split('\ndiff --git')[1:]:
8659
header = diff_header(diff)
8760

8861
a_path, b_path, similarity_index, rename_from, rename_to, \
8962
old_mode, new_mode, new_file_mode, deleted_file_mode, \
90-
a_blob, b_blob, b_mode = header.groups()
63+
a_commit, b_commit, b_mode = header.groups()
9164
new_file, deleted_file = bool(new_file_mode), bool(deleted_file_mode)
9265

93-
diffs.append(Diff(repo, a_path, b_path, a_blob, b_blob,
66+
diffs.append(Diff(repo, a_path, b_path, a_commit, b_commit,
9467
old_mode or deleted_file_mode, new_mode or new_file_mode or b_mode,
9568
new_file, deleted_file, rename_from, rename_to, diff[header.end():]))
9669

test/git/test_commit.py

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,18 @@ def test_diff(self, git):
3737

3838
assert_equal(15, len(diffs))
3939

40-
assert_equal('.gitignore', diffs[0].a_blob.name)
41-
assert_equal('.gitignore', diffs[0].b_blob.name)
42-
assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id)
43-
assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id)
44-
assert_equal('100644', diffs[0].b_blob.mode)
40+
assert_equal('.gitignore', diffs[0].a_path)
41+
assert_equal('.gitignore', diffs[0].b_path)
42+
assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_commit.id)
43+
assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_commit.id)
44+
assert_equal('100644', diffs[0].b_mode)
4545
assert_equal(False, diffs[0].new_file)
4646
assert_equal(False, diffs[0].deleted_file)
4747
assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff)
4848

49-
assert_equal('lib/grit/actor.rb', diffs[5].b_blob.name)
50-
assert_equal(None, diffs[5].a_blob)
51-
assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id)
52-
assert_equal( None, diffs[5].a_mode )
49+
assert_equal('lib/grit/actor.rb', diffs[5].a_path)
50+
assert_equal(None, diffs[5].a_commit)
51+
assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_commit.id)
5352
assert_equal(True, diffs[5].new_file)
5453

5554
assert_true(git.called)
@@ -89,7 +88,7 @@ def test_diff_with_files(self, git):
8988
diffs = Commit.diff(self.repo, '59ddc32', ['lib'])
9089

9190
assert_equal(1, len(diffs))
92-
assert_equal('lib/grit/diff.rb', diffs[0].a_blob.name)
91+
assert_equal('lib/grit/diff.rb', diffs[0].a_path)
9392

9493
assert_true(git.called)
9594
assert_equal(git.call_args, (('diff', '-M', '59ddc32', '--', 'lib'), {'full_index': True}))
@@ -101,7 +100,7 @@ def test_diff_with_two_commits_and_files(self, git):
101100
diffs = Commit.diff(self.repo, '59ddc32', '13d27d5', ['lib'])
102101

103102
assert_equal(1, len(diffs))
104-
assert_equal('lib/grit/commit.rb', diffs[0].a_blob.name)
103+
assert_equal('lib/grit/commit.rb', diffs[0].a_path)
105104

106105
assert_true(git.called)
107106
assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5', '--', 'lib'), {'full_index': True}))
@@ -115,18 +114,18 @@ def test_diffs(self, git):
115114

116115
assert_equal(15, len(diffs))
117116

118-
assert_equal('.gitignore', diffs[0].a_blob.name)
119-
assert_equal('.gitignore', diffs[0].b_blob.name)
120-
assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id)
121-
assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id)
122-
assert_equal('100644', diffs[0].b_blob.mode)
117+
assert_equal('.gitignore', diffs[0].a_path)
118+
assert_equal('.gitignore', diffs[0].b_path)
119+
assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_commit.id)
120+
assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_commit.id)
121+
assert_equal('100644', diffs[0].b_mode)
123122
assert_equal(False, diffs[0].new_file)
124123
assert_equal(False, diffs[0].deleted_file)
125124
assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff)
126125

127-
assert_equal('lib/grit/actor.rb', diffs[5].b_blob.name)
128-
assert_equal(None, diffs[5].a_blob)
129-
assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id)
126+
assert_equal('lib/grit/actor.rb', diffs[5].a_path)
127+
assert_equal(None, diffs[5].a_commit)
128+
assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_commit.id)
130129
assert_equal(True, diffs[5].new_file)
131130

132131
assert_true(git.called)
@@ -145,17 +144,18 @@ def test_diffs_on_initial_import(self, git):
145144

146145
assert_equal(10, len(diffs))
147146

148-
assert_equal('History.txt', diffs[0].b_blob.name)
149-
assert_equal(None, diffs[0].a_blob)
150-
assert_equal('100644', diffs[0].b_blob.mode)
151-
assert_equal('81d2c27608b352814cbe979a6acd678d30219678', diffs[0].b_blob.id)
147+
assert_equal('History.txt', diffs[0].a_path)
148+
assert_equal('History.txt', diffs[0].b_path)
149+
assert_equal(None, diffs[0].a_commit)
150+
assert_equal('100644', diffs[0].b_mode)
151+
assert_equal('81d2c27608b352814cbe979a6acd678d30219678', diffs[0].b_commit.id)
152152
assert_equal(True, diffs[0].new_file)
153153
assert_equal(False, diffs[0].deleted_file)
154154
assert_equal("--- /dev/null\n+++ b/History.txt\n@@ -0,0 +1,5 @@\n+== 1.0.0 / 2007-10-09\n+\n+* 1 major enhancement\n+ * Birthday!\n+", diffs[0].diff)
155155

156-
assert_equal('lib/grit.rb', diffs[5].b_blob.name)
157-
assert_equal(None, diffs[5].a_blob)
158-
assert_equal('32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].b_blob.id)
156+
assert_equal('lib/grit.rb', diffs[5].a_path)
157+
assert_equal(None, diffs[5].a_commit)
158+
assert_equal('32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].b_commit.id)
159159
assert_equal(True, diffs[5].new_file)
160160

161161
assert_true(git.called)
@@ -181,10 +181,7 @@ def test_diffs_with_mode_only_change(self, git):
181181
commit.__bake_it__()
182182
diffs = commit.diffs
183183

184-
# in case of mode-only changes, there is no blob
185184
assert_equal(23, len(diffs))
186-
assert_equal(None, diffs[0].a_blob)
187-
assert_equal(None, diffs[0].b_blob)
188185
assert_equal('100644', diffs[0].a_mode)
189186
assert_equal('100755', diffs[0].b_mode)
190187

0 commit comments

Comments
 (0)