diff options
-rw-r--r-- | git_review/cmd.py | 13 | ||||
-rw-r--r-- | git_review/tests/test_unit.py | 2 | ||||
-rw-r--r-- | releasenotes/notes/scp-subsystem-c8d78aa8f7f69f66.yaml | 15 | ||||
-rw-r--r-- | setup.cfg | 8 | ||||
-rw-r--r-- | test-requirements.txt | 1 |
5 files changed, 30 insertions, 9 deletions
diff --git a/git_review/cmd.py b/git_review/cmd.py index ea09278..5b65812 100644 --- a/git_review/cmd.py +++ b/git_review/cmd.py @@ -373,9 +373,17 @@ def set_hooks_commit_msg(remote, target_file): userhost = hostname # OS independent target file scp_target_file = target_file.replace(os.sep, "/") + + # Get scp options + scp_out = run_command("scp") + scp_opts = scp_out[scp_out.index("[") + 2:scp_out.index("]")] + cmd = ["scp", userhost + ":hooks/commit-msg", scp_target_file] if port is not None: cmd.insert(1, "-P%s" % port) + # Force scp protocol if the -O option is available + if "O" in scp_opts: + cmd.insert(1, "-O") if VERBOSE: hook_url = 'scp://%s%s/hooks/commit-msg' \ @@ -1005,7 +1013,10 @@ def assert_one_change(remote, branch, yes, have_hook): "branches (for independent changes).") print("\nThe outstanding commits are:\n\n%s\n\n" "Do you really want to submit the above commits?" % output) - yes_no = input("Type 'yes' to confirm, other to cancel: ") + try: + yes_no = input("Type 'yes' to confirm, other to cancel: ") + except KeyboardInterrupt: + yes_no = "no" if yes_no.lower().strip() != "yes": print("Aborting.") sys.exit(1) diff --git a/git_review/tests/test_unit.py b/git_review/tests/test_unit.py index 7dc0c0e..1bbdbff 100644 --- a/git_review/tests/test_unit.py +++ b/git_review/tests/test_unit.py @@ -21,9 +21,9 @@ import io import os import sys import textwrap +from unittest import mock import fixtures -import mock import testtools from git_review import cmd diff --git a/releasenotes/notes/scp-subsystem-c8d78aa8f7f69f66.yaml b/releasenotes/notes/scp-subsystem-c8d78aa8f7f69f66.yaml new file mode 100644 index 0000000..1521445 --- /dev/null +++ b/releasenotes/notes/scp-subsystem-c8d78aa8f7f69f66.yaml @@ -0,0 +1,15 @@ +--- +fixes: + - | + OpenSSH has deprecated its use of scp/rcp protocol in favor of + SFTP, which the embedded Apache mina-sshd in widely-deployed + Gerrit versions does not yet support. The default officially + changed in OpenSSH 9.0 (some distributions, such as Fedora and + CentOS, switched their default behavior to this as early as + OpenSSH 8.7 or 8.8), leading to a ``subsystem request failed on + channel 0`` error during commit-msg hook retrieval. Now + git-review will attempt to detect whether scp's -O option is + available to force use of the legacy scp/rcp protocol, and apply + it if so. Future git-review versions may change the fallback + behavior once an SFTP subsystem is implemented and available for + a new Gerrit release. @@ -4,7 +4,7 @@ summary = Tool to submit code to Gerrit long_description = file: README.rst long_description_content_type = text/x-rst; charset=UTF-8 author = OpenDev Contributors -author-email = service-discuss@lists.opendev.org +author_email = service-discuss@lists.opendev.org url = http://docs.opendev.org/opendev/git-review project_urls = Browse Source = https://opendev.org/opendev/git-review @@ -15,9 +15,6 @@ project_urls = Release Notes = https://docs.opendev.org/opendev/git-review/latest/releasenotes.html keywords = git gerrit review commandline license = Apache License, Version 2.0 -license_files = - AUTHORS - LICENSE classifiers = Development Status :: 5 - Production/Stable Environment :: Console @@ -33,7 +30,7 @@ classifiers = Programming Language :: Python :: 3.9 Programming Language :: Python Topic :: Utilities -python-requires = >= 3.5 +python_requires = >= 3.5 [files] packages = @@ -46,4 +43,3 @@ console_scripts = [pbr] manpages = git-review.1 -warnerrors = True diff --git a/test-requirements.txt b/test-requirements.txt index c175511..c61b89b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,6 @@ # due to non SNI TLS connections being disabled. pbr ; python_version >= "3" and python_version <= "3.5" hacking>=2.0.0,<2.1.0 -mock fixtures>=0.3.14 stestr>=2.2.0,<3.0.0 testtools>=0.9.34 |