diff --git a/gerrit_util.py b/gerrit_util.py index 6668756046..89ac990612 100644 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -146,8 +146,11 @@ class CookiesAuthenticator(Authenticator): assert not host.startswith('http') # Assume *.googlesource.com pattern. parts = host.split('.') - if not parts[0].endswith('-review'): - parts[0] += '-review' + + # remove -review suffix if present. + if parts[0].endswith('-review'): + parts[0] = parts[0][:-len('-review')] + return 'https://%s/new-password' % ('.'.join(parts)) @classmethod diff --git a/tests/gerrit_util_test.py b/tests/gerrit_util_test.py index d22b41723b..96d28b4aab 100755 --- a/tests/gerrit_util_test.py +++ b/tests/gerrit_util_test.py @@ -105,20 +105,19 @@ class CookiesAuthenticatorTest(unittest.TestCase): def testGetNewPasswordUrl(self): auth = gerrit_util.CookiesAuthenticator() + self.assertEqual('https://chromium.googlesource.com/new-password', + auth.get_new_password_url('chromium.googlesource.com')) self.assertEqual( - 'https://chromium-review.googlesource.com/new-password', - auth.get_new_password_url('chromium.googlesource.com')) - self.assertEqual( - 'https://chrome-internal-review.googlesource.com/new-password', + 'https://chrome-internal.googlesource.com/new-password', auth.get_new_password_url('chrome-internal-review.googlesource.com')) def testGetNewPasswordMessage(self): auth = gerrit_util.CookiesAuthenticator() self.assertIn( - 'https://chromium-review.googlesource.com/new-password', + 'https://chromium.googlesource.com/new-password', auth.get_new_password_message('chromium-review.googlesource.com')) self.assertIn( - 'https://chrome-internal-review.googlesource.com/new-password', + 'https://chrome-internal.googlesource.com/new-password', auth.get_new_password_message('chrome-internal.googlesource.com')) def testGetGitcookiesPath(self): diff --git a/tests/git_cl_creds_check_report.txt b/tests/git_cl_creds_check_report.txt index 4680043cd6..b513bce540 100644 --- a/tests/git_cl_creds_check_report.txt +++ b/tests/git_cl_creds_check_report.txt @@ -19,6 +19,6 @@ You can manually remove corresponding lines in your ~%(sep)s.gitcookies file and visit the following URLs with correct account to generate correct credential lines: - https://conflict-review.googlesource.com/new-password - https://gpartial-review.googlesource.com/new-password - https://partial-review.googlesource.com/new-password + https://conflict.googlesource.com/new-password + https://gpartial.googlesource.com/new-password + https://partial.googlesource.com/new-password diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index f4e884e38c..a43cfef716 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -2329,7 +2329,7 @@ class TestGitCl(unittest.TestCase): 'These are read from ~%(sep)s.gitcookies ' '(or legacy ~%(sep)s%(netrc)s)\n' 'You can (re)generate your credentials by visiting ' - 'https://chromium-review.googlesource.com/new-password\n' % { + 'https://chromium.googlesource.com/new-password\n' % { 'sep': os.sep, 'netrc': NETRC_FILENAME, }, sys.stderr.getvalue())