diff options
Diffstat (limited to 'pygerrit/client.py')
| -rw-r--r-- | pygerrit/client.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/pygerrit/client.py b/pygerrit/client.py index 9f34ef8..6afb94d 100644 --- a/pygerrit/client.py +++ b/pygerrit/client.py @@ -50,19 +50,22 @@ class GerritClient(object): return self._ssh_client.get_remote_version() def query(self, term): - """ Run `gerrit query` with the given term. + """ Run `gerrit query` with the given `term`. Return a list of results as `Change` objects. + Raise `ValueError` if `term` is not a string. + """ results = [] command = ["query", "--current-patch-set", "--all-approvals", "--format JSON", "--commit-message"] - if isinstance(term, list): - command += [escape_string(" ".join(term))] - else: - command += [escape_string(term)] - result = self._ssh_client.run_gerrit_command(command) + + if not isinstance(term, basestring): + raise ValueError("term must be a string") + + command.append(escape_string(term)) + result = self._ssh_client.run_gerrit_command(" ".join(command)) decoder = JSONDecoder() for line in result.stdout.read().splitlines(): # Gerrit's response to the query command contains one or more |
