Correct git review -l over http(s)

Previously git review -l over http(s) returned open changes for all
projects.

Change-Id: Id8feb199286f9bb838d28f624768726977c07bae
This commit is contained in:
Cedric Brandily
2014-05-26 12:07:55 +02:00
parent cb87cd1dd8
commit dbdb65a556
2 changed files with 36 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ if sys.version < '3':
import ConfigParser
import urllib
import urlparse
urlencode = urllib.urlencode
urljoin = urlparse.urljoin
urlparse = urlparse.urlparse
do_input = raw_input
@@ -41,6 +42,7 @@ else:
import configparser as ConfigParser
import urllib.parse
import urllib.request
urlencode = urllib.parse.urlencode
urljoin = urllib.parse.urljoin
urlparse = urllib.parse.urlparse
do_input = input
@@ -422,6 +424,10 @@ def query_reviews_over_http(remote_url, change=None, current_patch_set=True,
url += '?q=%s&o=CURRENT_REVISION' % change
else:
url += '?q=%s&o=ALL_REVISIONS' % change
else:
project_name = re.sub(r"^/|(\.git$)", "", urlparse(remote_url).path)
params = urlencode({'q': 'project:%s status:open' % project_name})
url += '?' + params
if VERBOSE:
print("Query gerrit %s" % url)

View File

@@ -194,6 +194,36 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
# we should push to '(...)/master', not '(...)/(detached'
self.assertTrue(review.strip().split('\n')[-1].endswith(curr_branch))
def test_git_review_l(self):
self._run_git_review('-s')
# Populate "project" repo
self._simple_change('project: test1', 'project: change1, merged')
self._simple_change('project: test2', 'project: change2, open')
self._simple_change('project: test3', 'project: change3, abandoned')
self._run_git_review('-y')
head = self._run_git('rev-parse', 'HEAD')
head_2 = self._run_git('rev-parse', 'HEAD^^')
self._run_gerrit_cli('review', head_2, '--code-review=+2', '--submit')
self._run_gerrit_cli('review', head, '--abandon')
# Populate "project2" repo
self._run_gerrit_cli('create-project', '--empty-commit', '--name',
'test/test_project2')
project2_uri = self.project_uri.replace('test/test_project',
'test/test_project2')
self._run_git('fetch', project2_uri, 'HEAD')
self._run_git('checkout', 'FETCH_HEAD')
self._simple_change('project2: test1', 'project2: change1, open')
self._run_git('push', project2_uri, 'HEAD:refs/for/master')
# Only project1 open changes
result = self._run_git_review('-l')
self.assertNotIn('project: change1, merged', result)
self.assertIn('project: change2, open', result)
self.assertNotIn('project: change3, abandoned', result)
self.assertNotIn('project2:', result)
class HttpGitReviewTestCase(tests.HttpMixin, GitReviewTestCase):
"""Class for the git-review tests over HTTP(S)."""