From 5a5537dc63194c2e164c961871d34955bd007581 Mon Sep 17 00:00:00 2001 From: Edward Lesmes Date: Wed, 1 Apr 2020 20:52:30 +0000 Subject: [PATCH] git-cl: Fix retrieving gitcookies path. Decode the result of reading http.cookiefile from git config Bug: 1066992 Change-Id: I1d4f2c8e54f717ef61ab4e630f3f66206c56047e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2132774 Reviewed-by: Josip Sokcevic Commit-Queue: Edward Lesmes --- gerrit_util.py | 5 +++-- tests/gerrit_util_test.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gerrit_util.py b/gerrit_util.py index 87884705c8..629d3a77c8 100644 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -203,8 +203,9 @@ class CookiesAuthenticator(Authenticator): if os.getenv('GIT_COOKIES_PATH'): return os.getenv('GIT_COOKIES_PATH') try: - return subprocess2.check_output( - ['git', 'config', '--path', 'http.cookiefile']).strip() + path = subprocess2.check_output( + ['git', 'config', '--path', 'http.cookiefile']) + return path.decode('utf-8', 'ignore').strip() except subprocess2.CalledProcessError: return os.path.expanduser(os.path.join('~', '.gitcookies')) diff --git a/tests/gerrit_util_test.py b/tests/gerrit_util_test.py index c4973333a8..a4994cbbd9 100644 --- a/tests/gerrit_util_test.py +++ b/tests/gerrit_util_test.py @@ -126,7 +126,7 @@ class CookiesAuthenticatorTest(unittest.TestCase): os.path.expanduser(os.path.join('~', '.gitcookies')), gerrit_util.CookiesAuthenticator().get_gitcookies_path()) - subprocess2.check_output.side_effect = ['http.cookiefile'] + subprocess2.check_output.side_effect = [b'http.cookiefile'] self.assertEqual( 'http.cookiefile', gerrit_util.CookiesAuthenticator().get_gitcookies_path())