Merge "Fix bug in git_credentials()"

This commit is contained in:
Zuul 2021-01-21 16:34:17 +00:00 committed by Gerrit Code Review
commit 23980a8b9d
2 changed files with 4 additions and 4 deletions

View File

@ -171,7 +171,7 @@ def git_credentials(url):
"""Return credentials using git credential or None."""
cmd = 'git', 'credential', 'fill'
stdin = 'url=%s' % url
rc, out = run_command_status(*cmd, stdin=stdin.encode('utf-8'))
rc, out = run_command_status(*cmd, stdin=stdin)
if rc:
return None
data = dict(line.split('=', 1) for line in out.splitlines())

View File

@ -305,7 +305,7 @@ class GitReviewUnitTest(testtools.TestCase):
# This gets encoded to utf8 which means the type passed down
# is bytes.
mock_run.assert_called_once_with('git', 'credential', 'fill',
stdin=b'url=%s' % url.encode('utf-8'))
stdin='url=%s' % url)
calls = [mock.call(url), mock.call(url, auth=('user', 'pass'))]
mock_get.assert_has_calls(calls)
@ -323,7 +323,7 @@ class GitReviewUnitTest(testtools.TestCase):
# This gets encoded to utf8 which means the type passed down
# is bytes.
mock_run.assert_called_once_with('git', 'credential', 'fill',
stdin=b'url=%s' % url.encode('utf-8'))
stdin='url=%s' % url)
calls = [mock.call(url), mock.call(url, auth=('user', 'pass'))]
mock_get.assert_has_calls(calls)
@ -341,7 +341,7 @@ class GitReviewUnitTest(testtools.TestCase):
# This gets encoded to utf8 which means the type passed down
# is bytes.
mock_run.assert_called_once_with('git', 'credential', 'fill',
stdin=b'url=%s' % url.encode('utf-8'))
stdin='url=%s' % url)
mock_get.assert_called_once_with(url)
@mock.patch('sys.argv', ['argv0', '--track', 'branch'])