summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-02-21 11:14:53 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-02-21 11:14:53 +0100
commit3236f8b966061b23ba063f3f7e1652764fee968f (patch)
treed7dda02f32de8e61f98a4d1aded6e5ef8dddd7ef
parente0acb8371bb2b68c2bda04db7cb2746ba3f9da86 (diff)
downloadgitpython-3236f8b966061b23ba063f3f7e1652764fee968f.tar.gz
`stale_refs()` may now also handle other kinds of references, like tags.
Fixes #260
-rw-r--r--git/remote.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/git/remote.py b/git/remote.py
index 8911aaa4..bb2165f2 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -455,7 +455,13 @@ class Remote(LazyMixin, Iterable):
remote side, but are still available locally.
The IterableList is prefixed, hence the 'origin' must be omitted. See
- 'refs' property for an example."""
+ 'refs' property for an example.
+
+ To make things more complicated, it can be possble for the list to include
+ other kinds of references, for example, tag references, if these are stale
+ as well. This is a fix for the issue described here:
+ https://github.com/gitpython-developers/GitPython/issues/260
+ """
out_refs = IterableList(RemoteReference._id_attribute_, "%s/" % self.name)
for line in self.repo.git.remote("prune", "--dry-run", self).splitlines()[2:]:
# expecting
@@ -463,8 +469,14 @@ class Remote(LazyMixin, Iterable):
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))
+ ref_name = line.replace(token, "")
+ # sometimes, paths start with a full ref name, like refs/tags/foo, see #260
+ if ref_name.startswith(Reference._common_path_default + '/'):
+ out_refs.append(SymbolicReference.from_path(self.repo, ref_name))
+ else:
+ fqhn = "%s/%s" % (RemoteReference._common_path_default, ref_name)
+ out_refs.append(RemoteReference(self.repo, fqhn))
+ # end special case handlin
# END for each line
return out_refs