summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2016-08-10 15:07:38 -0400
committerThibault Saunier <thibault.saunier@osg.samsung.com>2016-09-17 10:09:33 -0300
commite6950e10eb93fe197eb6d39f8ea2fcec8416865c (patch)
tree8453bdea801b55af13c9997cb30e8b68b7dbf334
parentf47cfd960028fd8be3a15e6e820ff7958f92a58c (diff)
Avoid trying to connect to phab when not needed
Making GitPhab.phabricator a @property so that we do not actually set connect when not calling it. Reviewed-by: Thibault Saunier <tsaunier@gnome.org> Differential Revision: https://phabricator.freedesktop.org/D1272
-rwxr-xr-xgit-phab25
1 files changed, 20 insertions, 5 deletions
diff --git a/git-phab b/git-phab
index 9978621..7943564 100755
--- a/git-phab
+++ b/git-phab
@@ -94,20 +94,26 @@ class GitPhab:
self.repo = git.Repo(os.getcwd(), search_parent_directories=True)
self.read_arcconfig()
- self.login()
- def login(self):
+ self._phabricator = None
+ self._phab_user = None
+
+ @property
+ def phabricator(self):
+ if self._phabricator:
+ return self._phabricator
+
needs_credential = False
try:
host = self.phabricator_uri + "/api/"
- self.phabricator = phabricator.Phabricator(timeout=120, host=host)
+ self._phabricator = phabricator.Phabricator(timeout=120, host=host)
if not self.phabricator.token and not self.phabricator.certificate:
needs_credential = True
# FIXME, workaround
# https://github.com/disqus/python-phabricator/issues/37
- self.phabricator.differential.creatediff.api.interface[
+ self._phabricator.differential.creatediff.api.interface[
"differential"]["creatediff"]["required"]["changes"] = dict
except phabricator.ConfigurationError:
needs_credential = True
@@ -119,7 +125,16 @@ class GitPhab:
else:
self.die("Please setup login certificate before trying again")
- self.phab_user = self.phabricator.user.whoami()
+ return self._phabricator
+
+ @property
+ def phab_user(self):
+ if self._phab_user:
+ return self._phab_user
+
+ self._phab_user = self.phabricator.user.whoami()
+
+ return self._phab_user
def setup_login_certificate(self):
token = input("""LOGIN TO PHABRICATOR