|
9 | 9 |
|
10 | 10 | from actor import Actor |
11 | 11 | from lazy import LazyMixin |
12 | | -import tree |
| 12 | +from tree import Tree |
13 | 13 | import diff |
14 | 14 | import stats |
15 | 15 |
|
16 | 16 | class Commit(LazyMixin): |
17 | | - def __init__(self, repo, **kwargs): |
| 17 | + def __init__(self, repo, id, tree=None, author=None, authored_date=None, |
| 18 | + committer=None, committed_date=None, message=None, parents=None): |
18 | 19 | """ |
19 | 20 | Instantiate a new Commit |
20 | 21 |
|
@@ -42,29 +43,29 @@ def __init__(self, repo, **kwargs): |
42 | 43 | ``message`` |
43 | 44 | is the first line of the commit message |
44 | 45 |
|
| 46 | + ``parents`` |
| 47 | + is the list of the parents of the commit |
| 48 | +
|
45 | 49 | Returns |
46 | 50 | GitPython.Commit |
47 | 51 | """ |
48 | 52 | LazyMixin.__init__(self) |
49 | 53 |
|
50 | 54 | self.repo = repo |
51 | | - self.id = None |
52 | | - self.tree = None |
53 | | - self.author = None |
54 | | - self.authored_date = None |
55 | | - self.committer = None |
56 | | - self.committed_date = None |
57 | | - self.message = None |
| 55 | + self.id = id |
58 | 56 | self.parents = None |
59 | | - |
60 | | - for k, v in kwargs.items(): |
61 | | - setattr(self, k, v) |
| 57 | + self.tree = None |
| 58 | + self.author = author |
| 59 | + self.authored_date = authored_date |
| 60 | + self.committer = committer |
| 61 | + self.committed_date = committed_date |
| 62 | + self.message = message |
62 | 63 |
|
63 | 64 | if self.id: |
64 | | - if 'parents' in kwargs: |
65 | | - self.parents = map(lambda p: Commit(repo, id=p), kwargs['parents']) |
66 | | - if 'tree' in kwargs: |
67 | | - self.tree = tree.Tree(repo, id=kwargs['tree']) |
| 65 | + if parents is not None: |
| 66 | + self.parents = [Commit(repo, p) for p in parents] |
| 67 | + if tree is not None: |
| 68 | + self.tree = Tree(repo, id=tree) |
68 | 69 |
|
69 | 70 | def __bake__(self): |
70 | 71 | temp = Commit.find_all(self.repo, self.id, max_count=1)[0] |
|
0 commit comments