From 5687a7b2bdc2ce5abaeafe752625828428f59c22 Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Wed, 3 Feb 2016 12:43:02 +0000 Subject: [PATCH] Match name and result of is_detached() method Change the is_detached() method to negate the test within the method call, so that result is True if the tree is in a detached stage, instead of needing to invert the result from where the program calls the method. Change-Id: I30ea105fa354fcd975c134e87f9422d69864de9f --- git_upstream/lib/drop.py | 2 +- git_upstream/lib/importupstream.py | 2 +- git_upstream/lib/supersede.py | 2 +- git_upstream/lib/utils.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/git_upstream/lib/drop.py b/git_upstream/lib/drop.py index 7a7aca4..99a2b1f 100644 --- a/git_upstream/lib/drop.py +++ b/git_upstream/lib/drop.py @@ -69,7 +69,7 @@ class Drop(LogDedentMixin, GitMixin): self._author = author # test that we can use this git repo - if not self.is_detached(): + if self.is_detached(): raise DropError("In 'detached HEAD' state") # To Do: check if it possible and useful. diff --git a/git_upstream/lib/importupstream.py b/git_upstream/lib/importupstream.py index ed76f73..dc0772e 100644 --- a/git_upstream/lib/importupstream.py +++ b/git_upstream/lib/importupstream.py @@ -48,7 +48,7 @@ class ImportUpstream(LogDedentMixin, GitMixin): super(ImportUpstream, self).__init__(*args, **kwargs) # test that we can use this git repo - if not self.is_detached(): + if self.is_detached(): raise ImportUpstreamError("In 'detached HEAD' state") if self.repo.bare: diff --git a/git_upstream/lib/supersede.py b/git_upstream/lib/supersede.py index aa10ef6..423d32c 100644 --- a/git_upstream/lib/supersede.py +++ b/git_upstream/lib/supersede.py @@ -62,7 +62,7 @@ class Supersede(LogDedentMixin, GitMixin): raise SupersedeError("Commit should be provided") # test that we can use this git repo - if not self.is_detached(): + if self.is_detached(): raise SupersedeError("In 'detached HEAD' state") # To Do: check if it possible and useful. diff --git a/git_upstream/lib/utils.py b/git_upstream/lib/utils.py index b370063..ae34dda 100644 --- a/git_upstream/lib/utils.py +++ b/git_upstream/lib/utils.py @@ -53,7 +53,7 @@ class GitMixin(object): return self.__git def is_detached(self): - return self.git.symbolic_ref("HEAD", q=True, with_exceptions=False) + return not self.git.symbolic_ref("HEAD", q=True, with_exceptions=False) def get_name(self, sha1, pattern=None): """