| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 87afd25 commit 146a6fe
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,6 +117,11 @@ Repo | |||
| 117 | 117 | currently regex are used a lot although we can deduct what will be next. | |
| 118 | 118 | - Read data from a stream directly from git command | |
| 119 | 119 | * Figure out how to implement a proper merge API | |
| 120 | + * There should be a way to create refs and delete them, instead of having to use | ||
| 121 | + the awkward Head.create( repo, ... ) way | ||
| 122 | + * repo.checkout should be added that does everything HEAD.reset does, but in addition | ||
| 123 | + it allows to checkout heads beforehand, hence its more like a repo.head.reference = other_head. | ||
| 124 | + | ||
| 120 | 125 | ||
| 121 | 126 | Submodules | |
| 122 | 127 | ---------- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -256,9 +256,11 @@ def iter_items(cls, repo): | |||
| 256 | 256 | def refs(self): | |
| 257 | 257 | """ | |
| 258 | 258 | Returns | |
| 259 | - IterableList of RemoteReference objects | ||
| 259 | + IterableList of RemoteReference objects. It is prefixed, allowing | ||
| 260 | + you to omit the remote path portion, i.e.:: | ||
| 261 | + remote.refs.master # yields RemoteReference('/refs/remotes/origin/master') | ||
| 260 | 262 | """ | |
| 261 | - out_refs = IterableList(RemoteReference._id_attribute_) | ||
| 263 | + out_refs = IterableList(RemoteReference._id_attribute_, "%s/" % self.name) | ||
| 262 | 264 | for ref in RemoteReference.list_items(self.repo): | |
| 263 | 265 | if ref.remote_name == self.name: | |
| 264 | 266 | out_refs.append(ref) | |
@@ -274,8 +276,11 @@ def stale_refs(self): | |||
| 274 | 276 | IterableList RemoteReference objects that do not have a corresponding | |
| 275 | 277 | head in the remote reference anymore as they have been deleted on the | |
| 276 | 278 | remote side, but are still available locally. | |
| 279 | + | ||
| 280 | + The IterableList is prefixed, hence the 'origin' must be omitted. See | ||
| 281 | + 'refs' property for an example. | ||
| 277 | 282 | """ | |
| 278 | - out_refs = IterableList(RemoteReference._id_attribute_) | ||
| 283 | + out_refs = IterableList(RemoteReference._id_attribute_, "%s/" % self.name) | ||
| 279 | 284 | for line in self.repo.git.remote("prune", "--dry-run", self).splitlines()[2:]: | |
| 280 | 285 | # expecting | |
| 281 | 286 | # * [would prune] origin/new_branch | |
@@ -357,7 +362,6 @@ def update(self, **kwargs): | |||
| 357 | 362 | ||
| 358 | 363 | def _get_fetch_info_from_stderr(self, stderr): | |
| 359 | 364 | # skip first line as it is some remote info we are not interested in | |
| 360 | - print stderr | ||
| 361 | 365 | output = IterableList('name') | |
| 362 | 366 | err_info = stderr.splitlines()[1:] | |
| 363 | 367 | ||
@@ -426,7 +430,12 @@ def push(self, refspec=None, **kwargs): | |||
| 426 | 430 | Returns | |
| 427 | 431 | self | |
| 428 | 432 | """ | |
| 429 | - self.repo.git.push(self, refspec, **kwargs) | ||
| 433 | + proc = self.repo.git.push(self, refspec, porcelain=True, as_process=True, **kwargs) | ||
| 434 | + print "stdout"*10 | ||
| 435 | + print proc.stdout.read() | ||
| 436 | + print "stderr"*10 | ||
| 437 | + print proc.stderr.read() | ||
| 438 | + proc.wait() | ||
| 430 | 439 | return self | |
| 431 | 440 | ||
| 432 | 441 | @property | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -260,16 +260,25 @@ class IterableList(list): | |||
| 260 | 260 | heads.master | |
| 261 | 261 | heads['master'] | |
| 262 | 262 | heads[0] | |
| 263 | + | ||
| 264 | + It requires an id_attribute name to be set which will be queried from its | ||
| 265 | + contained items to have a means for comparison. | ||
| 266 | + | ||
| 267 | + A prefix can be specified which is to be used in case the id returned by the | ||
| 268 | + items always contains a prefix that does not matter to the user, so it | ||
| 269 | + can be left out. | ||
| 263 | 270 | """ | |
| 264 | - __slots__ = '_id_attr' | ||
| 271 | + __slots__ = ('_id_attr', '_prefix') | ||
| 265 | 272 | ||
| 266 | - def __new__(cls, id_attr): | ||
| 273 | + def __new__(cls, id_attr, prefix=''): | ||
| 267 | 274 | return super(IterableList,cls).__new__(cls) | |
| 268 | 275 | ||
| 269 | - def __init__(self, id_attr): | ||
| 276 | + def __init__(self, id_attr, prefix=''): | ||
| 270 | 277 | self._id_attr = id_attr | |
| 278 | + self._prefix = prefix | ||
| 271 | 279 | ||
| 272 | 280 | def __getattr__(self, attr): | |
| 281 | + attr = self._prefix + attr | ||
| 273 | 282 | for item in self: | |
| 274 | 283 | if getattr(item, self._id_attr) == attr: | |
| 275 | 284 | return item | |
@@ -283,7 +292,7 @@ def __getitem__(self, index): | |||
| 283 | 292 | try: | |
| 284 | 293 | return getattr(self, index) | |
| 285 | 294 | except AttributeError: | |
| 286 | - raise IndexError( "No item found with id %r" % index ) | ||
| 295 | + raise IndexError( "No item found with id %r" % self._prefix + index ) | ||
| 287 | 296 | ||
| 288 | 297 | class Iterable(object): | |
| 289 | 298 | """ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,7 @@ def _test_fetch_result(self, results, remote): | |||
| 23 | 23 | for info in results: | |
| 24 | 24 | if isinstance(info.ref, Reference): | |
| 25 | 25 | assert info.flags != 0 | |
| 26 | - # END referebce type flags handling | ||
| 26 | + # END reference type flags handling | ||
| 27 | 27 | assert isinstance(info.ref, (SymbolicReference, Reference)) | |
| 28 | 28 | if info.flags & info.FORCED_UPDATE: | |
| 29 | 29 | assert isinstance(info.commit_before_forced_update, Commit) | |
@@ -122,8 +122,26 @@ def get_info(res, remote, name): | |||
| 122 | 122 | res = fetch_and_test(remote, tags=True) | |
| 123 | 123 | self.failUnlessRaises(IndexError, get_info, res, remote, str(rtag)) | |
| 124 | 124 | ||
| 125 | + def _test_push_and_pull(self,remote, rw_repo, remote_repo): | ||
| 126 | + # push our changes | ||
| 127 | + lhead = rw_repo.head | ||
| 128 | + lindex = rw_repo.index | ||
| 129 | + # assure we are on master and it is checked out where the remote is | ||
| 130 | + lhead.reference = rw_repo.heads.master | ||
| 131 | + lhead.reset(remote.refs.master, working_tree=True) | ||
| 132 | + | ||
| 133 | + # push without spec should fail ( without further configuration ) | ||
| 134 | + # self.failUnlessRaises(GitCommandError, remote.push) | ||
| 135 | + | ||
| 136 | + new_file = self._make_file("new_file", "hello world", rw_repo) | ||
| 137 | + lindex.add([new_file]) | ||
| 138 | + lindex.commit("test commit") | ||
| 139 | + remote.push(lhead.reference) | ||
| 140 | + | ||
| 141 | + self.fail("test --all") | ||
| 142 | + self.fail("test rewind and force -push") | ||
| 143 | + self.fail("test general fail due to invalid refspec") | ||
| 125 | 144 | ||
| 126 | - def _test_pull(self,remote, rw_repo, remote_repo): | ||
| 127 | 145 | # pull is essentially a fetch + merge, hence we just do a light | |
| 128 | 146 | # test here, leave the reset to the actual merge testing | |
| 129 | 147 | # fails as we did not specify a branch and there is no configuration for it | |
@@ -184,7 +202,7 @@ def test_base(self, rw_repo, remote_repo): | |||
| 184 | 202 | self._test_fetch(remote, rw_repo, remote_repo) | |
| 185 | 203 | ||
| 186 | 204 | # PULL TESTING | |
| 187 | - self._test_pull(remote, rw_repo, remote_repo) | ||
| 205 | + self._test_push_and_pull(remote, rw_repo, remote_repo) | ||
| 188 | 206 | ||
| 189 | 207 | remote.update() | |
| 190 | 208 | # END for each remote | |
| Back | FazBrowse Home | New Git URL |
0 commit comments