summaryrefslogtreecommitdiff
path: root/lib/git/remote.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-27 22:06:18 +0100
committerSebastian Thiel <byronimo@gmail.com>2009-10-27 22:06:18 +0100
commitb1f32e231d391f8e6051957ad947d3659c196b2b (patch)
tree03df8a8872ba0b83a3dc59d88192522482de8928 /lib/git/remote.py
parent764cc6e344bd034360485018eb750a0e155ca1f6 (diff)
downloadgitpython-b1f32e231d391f8e6051957ad947d3659c196b2b.tar.gz
Added remote stale_refs property including test, tested new remote branch handling and deletion of stale remote branches
Diffstat (limited to 'lib/git/remote.py')
-rw-r--r--lib/git/remote.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/git/remote.py b/lib/git/remote.py
index d4ca9eb3..0c779f85 100644
--- a/lib/git/remote.py
+++ b/lib/git/remote.py
@@ -213,7 +213,7 @@ class Remote(LazyMixin, Iterable):
def refs(self):
"""
Returns
- List of RemoteRef objects
+ IterableList of RemoteReference objects
"""
out_refs = IterableList(RemoteReference._id_attribute_)
for ref in RemoteReference.list_items(self.repo):
@@ -223,6 +223,26 @@ class Remote(LazyMixin, Iterable):
# END for each ref
assert out_refs, "Remote %s did not have any references" % self.name
return out_refs
+
+ @property
+ def stale_refs(self):
+ """
+ Returns
+ IterableList RemoteReference objects that do not have a corresponding
+ head in the remote reference anymore as they have been deleted on the
+ remote side, but are still available locally.
+ """
+ out_refs = IterableList(RemoteReference._id_attribute_)
+ for line in self.repo.git.remote("prune", "--dry-run", self).splitlines()[2:]:
+ # expecting
+ # * [would prune] origin/new_branch
+ token = " * [would prune] "
+ if not line.startswith(token):
+ raise ValueError("Could not parse git-remote prune result: %r" % line)
+ fqhn = "%s/%s" % (RemoteReference._common_path_default,line.replace(token, ""))
+ out_refs.append(RemoteReference(self.repo, fqhn))
+ # END for each line
+ return out_refs
@classmethod
def create(cls, repo, name, url, **kwargs):