mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-04-02 14:09:18 +00:00
launcher: change RunResult to subprocess.CompletedProcess
Since we require Python 3.6 now in the launcher, swap out our custom RunResult class for the standard subprocess one. Change-Id: Idd8598df37c0a952d3ef828df6e250cab03c6589 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/462341 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
4b94e773ef
commit
243df2042e
12
repo
12
repo
@ -124,7 +124,7 @@ if not REPO_REV:
|
|||||||
BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
|
BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
|
||||||
|
|
||||||
# increment this whenever we make important changes to this script
|
# increment this whenever we make important changes to this script
|
||||||
VERSION = (2, 50)
|
VERSION = (2, 54)
|
||||||
|
|
||||||
# increment this if the MAINTAINER_KEYS block is modified
|
# increment this if the MAINTAINER_KEYS block is modified
|
||||||
KEYRING_VERSION = (2, 3)
|
KEYRING_VERSION = (2, 3)
|
||||||
@ -483,11 +483,6 @@ def InitParser(parser):
|
|||||||
|
|
||||||
|
|
||||||
# This is a poor replacement for subprocess.run until we require Python 3.6+.
|
# This is a poor replacement for subprocess.run until we require Python 3.6+.
|
||||||
RunResult = collections.namedtuple(
|
|
||||||
"RunResult", ("returncode", "stdout", "stderr")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class RunError(Exception):
|
class RunError(Exception):
|
||||||
"""Error when running a command failed."""
|
"""Error when running a command failed."""
|
||||||
|
|
||||||
@ -526,7 +521,9 @@ def run_command(cmd, **kwargs):
|
|||||||
elif stderr == subprocess.STDOUT:
|
elif stderr == subprocess.STDOUT:
|
||||||
dbg += " 2>&1"
|
dbg += " 2>&1"
|
||||||
trace.print(dbg)
|
trace.print(dbg)
|
||||||
ret = RunResult(proc.returncode, decode(stdout), decode(stderr))
|
ret = subprocess.CompletedProcess(
|
||||||
|
cmd, proc.returncode, decode(stdout), decode(stderr)
|
||||||
|
)
|
||||||
|
|
||||||
# If things failed, print useful debugging output.
|
# If things failed, print useful debugging output.
|
||||||
if check and ret.returncode:
|
if check and ret.returncode:
|
||||||
@ -553,7 +550,6 @@ def run_command(cmd, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
class CloneFailure(Exception):
|
class CloneFailure(Exception):
|
||||||
|
|
||||||
"""Indicate the remote clone of repo itself failed."""
|
"""Indicate the remote clone of repo itself failed."""
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
@ -358,8 +359,8 @@ class VerifyRev(RepoWrapperTestCase):
|
|||||||
|
|
||||||
def test_verify_passes(self):
|
def test_verify_passes(self):
|
||||||
"""Check when we have a valid signed tag."""
|
"""Check when we have a valid signed tag."""
|
||||||
desc_result = self.wrapper.RunResult(0, "v1.0\n", "")
|
desc_result = subprocess.CompletedProcess([], 0, "v1.0\n", "")
|
||||||
gpg_result = self.wrapper.RunResult(0, "", "")
|
gpg_result = subprocess.CompletedProcess([], 0, "", "")
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
self.wrapper, "run_git", side_effect=(desc_result, gpg_result)
|
self.wrapper, "run_git", side_effect=(desc_result, gpg_result)
|
||||||
):
|
):
|
||||||
@ -370,8 +371,8 @@ class VerifyRev(RepoWrapperTestCase):
|
|||||||
|
|
||||||
def test_unsigned_commit(self):
|
def test_unsigned_commit(self):
|
||||||
"""Check we fall back to signed tag when we have an unsigned commit."""
|
"""Check we fall back to signed tag when we have an unsigned commit."""
|
||||||
desc_result = self.wrapper.RunResult(0, "v1.0-10-g1234\n", "")
|
desc_result = subprocess.CompletedProcess([], 0, "v1.0-10-g1234\n", "")
|
||||||
gpg_result = self.wrapper.RunResult(0, "", "")
|
gpg_result = subprocess.CompletedProcess([], 0, "", "")
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
self.wrapper, "run_git", side_effect=(desc_result, gpg_result)
|
self.wrapper, "run_git", side_effect=(desc_result, gpg_result)
|
||||||
):
|
):
|
||||||
@ -382,7 +383,7 @@ class VerifyRev(RepoWrapperTestCase):
|
|||||||
|
|
||||||
def test_verify_fails(self):
|
def test_verify_fails(self):
|
||||||
"""Check we fall back to signed tag when we have an unsigned commit."""
|
"""Check we fall back to signed tag when we have an unsigned commit."""
|
||||||
desc_result = self.wrapper.RunResult(0, "v1.0-10-g1234\n", "")
|
desc_result = subprocess.CompletedProcess([], 0, "v1.0-10-g1234\n", "")
|
||||||
gpg_result = Exception
|
gpg_result = Exception
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
self.wrapper, "run_git", side_effect=(desc_result, gpg_result)
|
self.wrapper, "run_git", side_effect=(desc_result, gpg_result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user