diff options
Diffstat (limited to 'lib/git/remote.py')
| -rw-r--r-- | lib/git/remote.py | 22 | 
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): | 
