| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,6 +45,40 @@ objects Package | |||
| 45 | 45 | not affect you though unless you explicitly imported individual objects. If you just | |
| 46 | 46 | used the git package, names did not change. | |
| 47 | 47 | ||
| 48 | + Blob | ||
| 49 | + ---- | ||
| 50 | + * former 'name' member renamed to path as it suits the actual data better | ||
| 51 | + | ||
| 52 | + Commit | ||
| 53 | + ------ | ||
| 54 | + * 'count' method is not an instance method to increase its ease of use | ||
| 55 | + | ||
| 56 | + Config | ||
| 57 | + ------ | ||
| 58 | + * The git configuration can now be read and manipulated directly from within python | ||
| 59 | + using the GitConfigParser | ||
| 60 | + * Repo.config_reader returns a read-only parser | ||
| 61 | + * Repo.config_writer returns a read-write parser | ||
| 62 | + | ||
| 63 | + Diff | ||
| 64 | + ---- | ||
| 65 | + * Members a a_commit and b_commit renamed to a_blob and b_blob - they are populated | ||
| 66 | + with Blob objects if possible | ||
| 67 | + * Members a_path and b_path removed as this information is kept in the blobs | ||
| 68 | + * Diffs are now returned as DiffIndex allowing to more quickly find the kind of | ||
| 69 | + diffs you are interested in | ||
| 70 | + | ||
| 71 | + Diffing | ||
| 72 | + ------- | ||
| 73 | + * Commit and Tree objects now support diffing natively with a common interface to | ||
| 74 | + compare agains other Commits or Trees, against the working tree or against the index. | ||
| 75 | + | ||
| 76 | + Refs | ||
| 77 | + ---- | ||
| 78 | + * Will dynmically retrieve their object at the time of query to assure the information | ||
| 79 | + is actual. Recently objects would be cached, hence ref object not be safely kept | ||
| 80 | + persistent. | ||
| 81 | + | ||
| 48 | 82 | Repo | |
| 49 | 83 | ---- | |
| 50 | 84 | * Moved blame method from Blob to repo as it appeared to belong there much more. | |
@@ -73,24 +107,19 @@ Repo | |||
| 73 | 107 | - archive_tar_gz and archive_tar and replaced by archive method with different signature | |
| 74 | 108 | * 'commits' method has no max-count of returned commits anymore, it now behaves | |
| 75 | 109 | like git-rev-list | |
| 76 | - * 'untracked_files' property added, returning all currently untracked files | ||
| 77 | - | ||
| 78 | - Diff | ||
| 79 | - ---- | ||
| 80 | - * Members a a_commit and b_commit renamed to a_blob and b_blob - they are populated | ||
| 81 | - with Blob objects if possible | ||
| 82 | - * Members a_path and b_path removed as this information is kept in the blobs | ||
| 83 | - * Diffs are now returned as DiffIndex allowing to more quickly find the kind of | ||
| 84 | - diffs you are interested in | ||
| 110 | + * The following methods and properties were added | ||
| 111 | + - 'untracked_files' property, returning all currently untracked files | ||
| 112 | + - 'head', creates a head object | ||
| 113 | + - 'tag', creates a tag object | ||
| 114 | + - 'iter_trees' method | ||
| 115 | + - 'config_reader' property | ||
| 116 | + - 'config_writer' property | ||
| 85 | 117 | ||
| 86 | - Diffing | ||
| 87 | - ------- | ||
| 88 | - * Commit and Tree objects now support diffing natively with a common interface to | ||
| 89 | - compare agains other Commits or Trees, against the working tree or against the index. | ||
| 90 | - | ||
| 91 | - Blob | ||
| 92 | - ---- | ||
| 93 | - * former 'name' member renamed to path as it suits the actual data better | ||
| 118 | + Remote | ||
| 119 | + ------ | ||
| 120 | + * Added Remote object allowing easy access to remotes | ||
| 121 | + * Repo.remotes lists all remotes | ||
| 122 | + * Repo.remote returns a remote of the specified name if it exists | ||
| 94 | 123 | ||
| 95 | 124 | Tree | |
| 96 | 125 | ---- | |
@@ -102,24 +131,6 @@ Tree | |||
| 102 | 131 | * now mimics behaviour of a read-only list instead of a dict to maintain order. | |
| 103 | 132 | * content_from_string method is now private and not part of the public API anymore | |
| 104 | 133 | ||
| 105 | - Refs | ||
| 106 | - ---- | ||
| 107 | - * Will dynmically retrieve their object at the time of query to assure the information | ||
| 108 | - is actual. Recently objects would be cached, hence ref object not be safely kept | ||
| 109 | - persistent. | ||
| 110 | - | ||
| 111 | - Remote | ||
| 112 | - ------ | ||
| 113 | - * Added Remote object allowing easy access to remotes | ||
| 114 | - * Repo.remotes lists all remotes | ||
| 115 | - * Repo.remote returns a remote of the specified name if it exists | ||
| 116 | - | ||
| 117 | - Config | ||
| 118 | - ------ | ||
| 119 | - * The git configuration can now be read and manipulated directly from within python | ||
| 120 | - using the GitConfigParser | ||
| 121 | - * Repo.config_reader returns a read-only parser | ||
| 122 | - * Repo.config_writer returns a read-write parser | ||
| 123 | 134 | ||
| 124 | 135 | 0.1.6 | |
| 125 | 136 | ===== | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,16 +101,9 @@ def summary(self): | |||
| 101 | 101 | """ | |
| 102 | 102 | return self.message.split('\n', 1)[0] | |
| 103 | 103 | ||
| 104 | - @classmethod | ||
| 105 | - def count(cls, repo, rev, paths='', **kwargs): | ||
| 104 | + def count(self, paths='', **kwargs): | ||
| 106 | 105 | """ | |
| 107 | - Count the number of commits reachable from this revision | ||
| 108 | - | ||
| 109 | - ``repo`` | ||
| 110 | - is the Repo | ||
| 111 | - | ||
| 112 | - ``rev`` | ||
| 113 | - revision specifier, see git-rev-parse for viable options | ||
| 106 | + Count the number of commits reachable from this commit | ||
| 114 | 107 | ||
| 115 | 108 | ``paths`` | |
| 116 | 109 | is an optinal path or a list of paths restricting the return value | |
@@ -121,7 +114,7 @@ def count(cls, repo, rev, paths='', **kwargs): | |||
| 121 | 114 | Returns | |
| 122 | 115 | int | |
| 123 | 116 | """ | |
| 124 | - return len(repo.git.rev_list(rev, '--', paths, **kwargs).strip().splitlines()) | ||
| 117 | + return len(self.repo.git.rev_list(self.id, '--', paths, **kwargs).strip().splitlines()) | ||
| 125 | 118 | ||
| 126 | 119 | @classmethod | |
| 127 | 120 | def iter_items(cls, repo, rev, paths='', **kwargs): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -174,7 +174,7 @@ def commit(self): | |||
| 174 | 174 | return self.object | |
| 175 | 175 | ||
| 176 | 176 | ||
| 177 | - class TagRef(Reference): | ||
| 177 | + class TagReference(Head): | ||
| 178 | 178 | """ | |
| 179 | 179 | Class representing a lightweight tag reference which either points to a commit | |
| 180 | 180 | or to a tag object. In the latter case additional information, like the signature | |
@@ -219,9 +219,9 @@ def tag(self): | |||
| 219 | 219 | ||
| 220 | 220 | ||
| 221 | 221 | # provide an alias | |
| 222 | - Tag = TagRef | ||
| 222 | + Tag = TagReference | ||
| 223 | 223 | ||
| 224 | - class RemoteRef(Head): | ||
| 224 | + class RemoteReference(Head): | ||
| 225 | 225 | """ | |
| 226 | 226 | Represents a reference pointing to a remote head. | |
| 227 | 227 | """ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | """ | |
| 9 | 9 | ||
| 10 | 10 | from git.utils import LazyMixin, Iterable | |
| 11 | - from refs import RemoteRef | ||
| 11 | + from refs import RemoteReference | ||
| 12 | 12 | ||
| 13 | 13 | class _SectionConstraint(object): | |
| 14 | 14 | """ | |
@@ -105,7 +105,7 @@ def iter_items(cls, repo): | |||
| 105 | 105 | # parse them using refs, as their query can be faster as it is | |
| 106 | 106 | # purely based on the file system | |
| 107 | 107 | seen_remotes = set() | |
| 108 | - for ref in RemoteRef.iter_items(repo): | ||
| 108 | + for ref in RemoteReference.iter_items(repo): | ||
| 109 | 109 | remote_name = ref.remote_name | |
| 110 | 110 | if remote_name in seen_remotes: | |
| 111 | 111 | continue | |
@@ -121,7 +121,7 @@ def refs(self): | |||
| 121 | 121 | List of RemoteRef objects | |
| 122 | 122 | """ | |
| 123 | 123 | out_refs = list() | |
| 124 | - for ref in RemoteRef.list_items(self.repo): | ||
| 124 | + for ref in RemoteReference.list_items(self.repo): | ||
| 125 | 125 | if ref.remote_name == self.name: | |
| 126 | 126 | out_refs.append(ref) | |
| 127 | 127 | # END if names match | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,6 +108,20 @@ def heads(self): | |||
| 108 | 108 | ``git.Head[]`` | |
| 109 | 109 | """ | |
| 110 | 110 | return Head.list_items(self) | |
| 111 | + | ||
| 112 | + # alias heads | ||
| 113 | + branches = heads | ||
| 114 | + | ||
| 115 | + @property | ||
| 116 | + def head(self,path="HEAD"): | ||
| 117 | + """ | ||
| 118 | + Return | ||
| 119 | + Head Object, reference pointing to commit | ||
| 120 | + | ||
| 121 | + ``path`` | ||
| 122 | + path to the head or its name, i.e. master or heads/master | ||
| 123 | + """ | ||
| 124 | + return Head(self,path) | ||
| 111 | 125 | ||
| 112 | 126 | @property | |
| 113 | 127 | def remotes(self): | |
@@ -130,18 +144,6 @@ def remote(self, name='origin'): | |||
| 130 | 144 | # END for each existing remote | |
| 131 | 145 | raise ValueError( "Remote named %s does not exist" % name ) | |
| 132 | 146 | ||
| 133 | - # alias heads | ||
| 134 | - branches = heads | ||
| 135 | - | ||
| 136 | - @property | ||
| 137 | - def head(self): | ||
| 138 | - """ | ||
| 139 | - Return | ||
| 140 | - Head Object, reference pointing to the current head of the repository | ||
| 141 | - """ | ||
| 142 | - return Head(self,'HEAD') | ||
| 143 | - | ||
| 144 | - | ||
| 145 | 147 | @property | |
| 146 | 148 | def tags(self): | |
| 147 | 149 | """ | |
@@ -150,7 +152,17 @@ def tags(self): | |||
| 150 | 152 | Returns | |
| 151 | 153 | ``git.Tag[]`` | |
| 152 | 154 | """ | |
| 153 | - return Tag.list_items(self) | ||
| 155 | + return TagReference.list_items(self) | ||
| 156 | + | ||
| 157 | + def tag(self,path): | ||
| 158 | + """ | ||
| 159 | + Return | ||
| 160 | + TagReference Object, reference pointing to a Commit or Tag | ||
| 161 | + | ||
| 162 | + ``path`` | ||
| 163 | + path to the tag reference, i.e. 0.1.5 or tags/0.1.5 | ||
| 164 | + """ | ||
| 165 | + return TagReference(self, path) | ||
| 154 | 166 | ||
| 155 | 167 | def _get_config_path(self, config_level ): | |
| 156 | 168 | # we do not support an absolute path of the gitconfig on windows , | |
@@ -214,6 +226,15 @@ def commit(self, rev=None): | |||
| 214 | 226 | c = Object.new(self, rev) | |
| 215 | 227 | assert c.type == "commit", "Revision %s did not point to a commit, but to %s" % (rev, c) | |
| 216 | 228 | return c | |
| 229 | + | ||
| 230 | + def iter_trees(self, *args, **kwargs): | ||
| 231 | + """ | ||
| 232 | + Returns | ||
| 233 | + Iterator yielding Tree objects | ||
| 234 | + | ||
| 235 | + Note: Takes all arguments known to iter_commits method | ||
| 236 | + """ | ||
| 237 | + return ( c.tree for c in self.iter_commits(*args, **kwargs) ) | ||
| 217 | 238 | ||
| 218 | 239 | def tree(self, ref=None): | |
| 219 | 240 | """ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,7 +66,7 @@ def test_rev_list_bisect_all(self, git): | |||
| 66 | 66 | assert_equal(sha1, commit.id) | |
| 67 | 67 | ||
| 68 | 68 | def test_count(self): | |
| 69 | - assert Commit.count( self.repo, '0.1.5' ) == 141 | ||
| 69 | + assert self.repo.tag('0.1.5').commit.count( ) == 141 | ||
| 70 | 70 | ||
| 71 | 71 | def test_str(self): | |
| 72 | 72 | commit = Commit(self.repo, id='abc') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,6 +67,16 @@ def test_commits(self, git): | |||
| 67 | 67 | ||
| 68 | 68 | assert_true(git.called) | |
| 69 | 69 | ||
| 70 | + def test_trees(self): | ||
| 71 | + mc = 30 | ||
| 72 | + num_trees = 0 | ||
| 73 | + for tree in self.repo.iter_trees('0.1.5', max_count=mc): | ||
| 74 | + num_trees += 1 | ||
| 75 | + assert isinstance(tree, Tree) | ||
| 76 | + # END for each tree | ||
| 77 | + assert num_trees == mc | ||
| 78 | + | ||
| 79 | + | ||
| 70 | 80 | @patch_object(Repo, '__init__') | |
| 71 | 81 | @patch_object(Git, '_call_process') | |
| 72 | 82 | def test_init(self, git, repo): | |
@@ -170,6 +180,9 @@ def test_active_branch(self, git): | |||
| 170 | 180 | def test_head(self): | |
| 171 | 181 | assert self.repo.head.object == self.repo.active_branch.object | |
| 172 | 182 | ||
| 183 | + def test_tag(self): | ||
| 184 | + assert self.repo.tag('0.1.5').commit | ||
| 185 | + | ||
| 173 | 186 | @patch_object(Git, '_call_process') | |
| 174 | 187 | def test_should_display_blame_information(self, git): | |
| 175 | 188 | git.return_value = fixture('blame') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments