summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-11-06 20:09:50 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-11-07 18:51:48 +0900
commitd47a4bc16d5a4aa23ce55a75bd4ef117425a5ed7 (patch)
treef3a671dc45d4b49d884437363e4f74d46a63b4f8
parentd7d9e95768aaeca99625e1876f1f75702812e54a (diff)
downloadpygerrit-d47a4bc16d5a4aa23ce55a75bd4ef117425a5ed7.tar.gz
Add method to get username and Gerrit version
If the username is not given in the constructor, it is detected from the ssh config. Add a method that allows the client to get the detected username that was used to connect to Gerrit. Change-Id: I15747d1446b07ce6b250f294fe72842a1be50a6c
-rw-r--r--pygerrit/client.py4
-rw-r--r--pygerrit/ssh.py5
2 files changed, 9 insertions, 0 deletions
diff --git a/pygerrit/client.py b/pygerrit/client.py
index 456ce2e..a5a27c4 100644
--- a/pygerrit/client.py
+++ b/pygerrit/client.py
@@ -47,6 +47,10 @@ class GerritClient(object):
""" Return the version of Gerrit that is connected to. """
return self._ssh_client.get_remote_version()
+ def gerrit_info(self):
+ """ Return the username, and version of Gerrit that is connected to. """
+ return self._ssh_client.get_remote_info()
+
def query(self, term):
""" Run `gerrit query` with the given `term`.
diff --git a/pygerrit/ssh.py b/pygerrit/ssh.py
index e779715..2933ddf 100644
--- a/pygerrit/ssh.py
+++ b/pygerrit/ssh.py
@@ -147,6 +147,11 @@ class GerritSSHClient(SSHClient):
self.remote_version = _extract_version(version_string, pattern)
return self.remote_version
+ def get_remote_info(self):
+ """ Return the username, and version of the remote Gerrit server. """
+ version = self.get_remote_version()
+ return (self.username, version)
+
def run_gerrit_command(self, command):
""" Run the given command.