commit git-review for openSUSE:Factory
Hello community, here is the log from the commit of package git-review for openSUSE:Factory checked in at 2019-05-07 23:18:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/git-review (Old) and /work/SRC/openSUSE:Factory/.git-review.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "git-review" Tue May 7 23:18:09 2019 rev:14 rq:700471 version:1.28.0 Changes: -------- --- /work/SRC/openSUSE:Factory/git-review/git-review.changes 2019-01-21 10:47:59.512192413 +0100 +++ /work/SRC/openSUSE:Factory/.git-review.new.5148/git-review.changes 2019-05-07 23:18:10.628819672 +0200 @@ -1,0 +2,23 @@ +Fri May 3 18:08:45 UTC 2019 - Dirk Mueller <dmueller@suse.com> + +- revert switch to singlespec. This is an insane complexification + for no gain: git-review is a pure cli tool, not a module + to import, and we never had a working python2- version anyway + because all the tooling was excluded from packaging. So + don't create packages that are unusable and deprecated. + +------------------------------------------------------------------- +Fri May 3 17:54:51 UTC 2019 - Dirk Mueller <dmueller@suse.com> + +- update to 1.28.0 (bsc#1134089): + * Support for auto-configuration of topic names based on the + presence of keywords in the commit message is removed. Previously, + keywords such as bug, bp or lp followed by a number would result + in branch names containing the associated number, e.g. bug/123. + This feature was OpenStack specific, was a frequent source of bugs + and clearly wasn’t being used that often, given that StoryBoard + is a thing now and no one had updated this feature to handle that metadata. + + * Fixed usepushurl to work when a read-only mirror being used as origin does not contain refs/changes from gerrit. + +------------------------------------------------------------------- Old: ---- git-review-1.27.0.tar.gz New: ---- git-review-1.28.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ git-review.spec ++++++ --- /var/tmp/diff_new_pack.mJGRkP/_old 2019-05-07 23:18:11.052820571 +0200 +++ /var/tmp/diff_new_pack.mJGRkP/_new 2019-05-07 23:18:11.052820571 +0200 @@ -16,32 +16,33 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: git-review -Version: 1.27.0 +Version: 1.28.0 Release: 0 Summary: Tool to submit code to Gerrit License: Apache-2.0 Group: Development/Languages/Python URL: https://git.openstack.org/cgit/openstack-infra/git-review Source: https://files.pythonhosted.org/packages/source/g/%{name}/%{name}-%{version}.tar.gz -BuildRequires: %{python_module fixtures >= 0.3.14} -BuildRequires: %{python_module mock} -BuildRequires: %{python_module pbr} -BuildRequires: %{python_module requests >= 1.1} -BuildRequires: %{python_module setuptools} -BuildRequires: %{python_module testrepository >= 0.0.18} -BuildRequires: %{python_module testtools >= 0.9.34} BuildRequires: fdupes +# Note that this package is intentionally not using singlespec because +# it is not a library but a plain CLI tool, and it doesn't make sense to +# build a python2.x version of it anymore in 2019. BuildRequires: python-rpm-macros -Requires: python-requests >= 1.1 -Requires: python-setuptools +BuildRequires: python3-fixtures >= 0.3.14 +BuildRequires: python3-mock +BuildRequires: python3-pbr +BuildRequires: python3-requests >= 1.1 +BuildRequires: python3-setuptools +BuildRequires: python3-six +BuildRequires: python3-stestr +BuildRequires: python3-testtools >= 0.9.34 +Requires: python3-requests >= 1.1 +Requires: python3-setuptools +Requires: python3-six +Provides: python3-git-review = %version +Obsoletes: python3-git-review < %version BuildArch: noarch -%ifpython3 -Provides: git-review = %{version} -Obsoletes: git-review < %{version} -%endif -%python_subpackages %description A git command for submitting branches to Gerrit @@ -53,11 +54,10 @@ %setup -q -n git-review-%{version} %build -%python_build +%python3_build %install -%python_install -%python_expand %fdupes %{buildroot}%{$python_sitelib} +%python3_install %check # Can't be executed because it fetches java from web and launches own gerrit @@ -66,11 +66,11 @@ #$python -m git_review.tests.prepare #$python setup.py testr} -%files %{python_files} +%files %license LICENSE %doc AUTHORS README.rst -%{python_sitelib}/* -%python3_only %{_bindir}/git-review -%python3_only %{_mandir}/man1/git-review.1%{?ext_man} +%{python3_sitelib}/* +%{_bindir}/git-review +%{_mandir}/man1/git-review.1%{?ext_man} %changelog ++++++ git-review-1.27.0.tar.gz -> git-review-1.28.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/.stestr.conf new/git-review-1.28.0/.stestr.conf --- old/git-review-1.27.0/.stestr.conf 1970-01-01 01:00:00.000000000 +0100 +++ new/git-review-1.28.0/.stestr.conf 2019-04-08 22:07:09.000000000 +0200 @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=./git_review/tests +top_dir=./ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/.testr.conf new/git-review-1.28.0/.testr.conf --- old/git-review-1.27.0/.testr.conf 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/.testr.conf 1970-01-01 01:00:00.000000000 +0100 @@ -1,8 +0,0 @@ -[DEFAULT] -test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ - OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ - OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ - ${PYTHON:-python} -m subunit.run discover -t ./ ./git_review/tests $LISTOPT $IDOPTION - -test_id_option=--load-list $IDFILE -test_list_option=--list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/AUTHORS new/git-review-1.28.0/AUTHORS --- old/git-review-1.27.0/AUTHORS 2018-09-19 20:00:55.000000000 +0200 +++ new/git-review-1.28.0/AUTHORS 2019-04-08 22:08:44.000000000 +0200 @@ -31,14 +31,17 @@ Dmitry Ratushnyy <dratushn@cisco.com> Doug Hellmann <doug@doughellmann.com> Eric Harney <eharney@redhat.com> +Fabio Porcedda <fabio.porcedda@gmail.com> Frederic Lepied <frederic.lepied@enovance.com> Han-Wen Nienhuys <hanwen@google.com> Hugh Saunders <hugh@wherenow.org> Ian Wienand <iwienand@redhat.com> Ian Y. Choi <ianyrchoi@gmail.com> +Ilya Etingof <etingof@gmail.com> JC Delay <jcd.delay@gmail.com> James E. Blair <james.blair@rackspace.com> James E. Blair <jeblair@linux.vnet.ibm.com> +Jan Kundrát <jan.kundrat@cesnet.cz> Jason Axelson <bostonvaulter@gmail.com> Jeremy Stanley <fungi@yuggoth.org> John Vandenberg <jayvdb@gmail.com> @@ -49,6 +52,7 @@ Krenair <krenair@gmail.com> Lorin Hochstein <lorin@isi.edu> Lukas Bednar <lbednar@redhat.com> +Marc Herbert <marc.herbert@gmail.com> Marcin Cieslak <saper@saper.info> Mark McLoughlin <markmc@redhat.com> Matthieu Baerts <matttbe@gmail.com> @@ -68,6 +72,7 @@ Sachi King <nakato@nakato.io> Saggi Mizrahi <smizrahi@redhat.com> Sorin Sbarnea <ssbarnea@redhat.com> +Stephen Finucane <stephenfin@redhat.com> Steve Kowalik <steven@wedontsleep.org> Swapnil Kulkarni (coolsvap) <me@coolsvap.net> Thomas Goirand <thomas@goirand.fr> @@ -77,7 +82,6 @@ Vishvananda Ishaya <vishvananda@gmail.com> Yuriy Taraday <yorik.sar@gmail.com> Zane Bitter <zbitter@redhat.com> -Zuul <zuul@review.openstack.org> david <dlenwell@gmail.com> gholt <z-launchpad@brim.net> julien.marinfrisonroche <julien.marinfrisonroche@thalesgroup.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/CONTRIBUTING.rst new/git-review-1.28.0/CONTRIBUTING.rst --- old/git-review-1.27.0/CONTRIBUTING.rst 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/CONTRIBUTING.rst 2019-04-08 22:07:09.000000000 +0200 @@ -16,13 +16,9 @@ Bugs are handled at: https://storyboard.openstack.org/#!/project/719 -There is a mailing list at: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-infra - Code reviews, as you might expect, are handled by gerrit at: https://review.openstack.org - -See http://wiki.openstack.org/GerritWorkflow for details. Pull -requests submitted through GitHub will be ignored. +Pull requests submitted through GitHub will be ignored. Use ``git review`` to submit patches (after creating a gerrit account that links to your launchpad account). Example:: @@ -30,3 +26,13 @@ # Do your commits git review # Enter your username if prompted + +The code review process is documented at +https://docs.openstack.org/infra/manual/developers.html If that process is +not enough to get reviewers' attention then try these (in that order): + +1. Use git log and git blame to find "who last touched the file" and add + them. Make sure they're still active on https://review.openstack.org +2. Ping the #openstack-infra IRC channel, see developers.html above. +3. As a last resort, mailing-list at: + http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-infra diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/ChangeLog new/git-review-1.28.0/ChangeLog --- old/git-review-1.27.0/ChangeLog 2018-09-19 20:00:55.000000000 +0200 +++ new/git-review-1.28.0/ChangeLog 2019-04-08 22:08:44.000000000 +0200 @@ -1,6 +1,34 @@ CHANGES ======= +1.28.0 +------ + +* Use remote\_url instead of remote for download +* Support usernames that contain '@' and ssh Git URLs +* Switch from testrepository to stestr +* Allow user to control Java version used by tox +* Fix wrong and misleading "using default: None" in --verbose mode +* Add hint to just "git remote rename origin gerrit" when no .gitreview +* tox.ini: add passenv = http\_proxy https\_proxy # \_JAVA\_OPTIONS +* CONTRIBUTING.rst, HACKING.rst: fix broken link, minor flow updates +* test\_uploads\_with\_nondefault\_rebase: fix git screen scraping +* tests/\_\_init\_\_.py: ssh-keygen -m PEM for bouncycastle +* Use six for cross python compatibility +* Avoid UnicodeEncodeError on python 2 +* As suggested by pep8 don't compare boolean values or empty sequences +* Improve exit code implementation +* docs: Call out use of an agent to store SSH passwords +* Don't set topic when submitting no-topic patches +* Remove auto-branch name +* tox: Remove dead settings/targets +* docs: Misc updates + +1.27.1.0a1 +---------- + +* Clean up vestigal scripting in cmd.py + 1.27.0 ------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/HACKING.rst new/git-review-1.28.0/HACKING.rst --- old/git-review-1.27.0/HACKING.rst 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/HACKING.rst 2019-04-08 22:07:09.000000000 +0200 @@ -244,7 +244,10 @@ `testr run --parallel`, but is set up such that you can supply any additional testr arguments that are needed to tox. For example, you can run: `tox -- --analyze-isolation` to cause tox to tell testr to add ---analyze-isolation to its argument list. +--analyze-isolation to its argument list. Arguments past ``--`` are passed +through to testr, for instance to run a single test:: + + tox -e py36 -- git_review.tests.test_unit.SomeClass.some_test It is also possible to run the tests inside of a virtual environment you have created, or it is possible that you have all of the dependencies diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/PKG-INFO new/git-review-1.28.0/PKG-INFO --- old/git-review-1.27.0/PKG-INFO 2018-09-19 20:00:56.000000000 +0200 +++ new/git-review-1.28.0/PKG-INFO 2019-04-08 22:08:44.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: git-review -Version: 1.27.0 +Version: 1.28.0 Summary: Tool to submit code to Gerrit Home-page: http://docs.openstack.org/infra/git-review/ Author: OpenStack diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/doc/source/developing.rst new/git-review-1.28.0/doc/source/developing.rst --- old/git-review-1.27.0/doc/source/developing.rst 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/doc/source/developing.rst 2019-04-08 22:07:09.000000000 +0200 @@ -9,15 +9,11 @@ * a Java Runtime Environment on the machine to run tests on -* Internet access to download the gerrit.war file, or a locally - cached copy (it needs to be located in a .gerrit directory at the +* Internet access to download the ``gerrit.war`` file, or a locally + cached copy (it needs to be located in a ``.gerrit`` directory at the top level of the git-review project) -To run git-review integration tests the following commands may by run:: +To run git-review integration tests, use tox. For example, to test against +Python 3.7:: - tox -e py27 - tox -e py26 - tox -e py32 - tox -e py33 - -depending on what Python interpreter would you like to use. + tox -e py37 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/doc/source/index.rst new/git-review-1.28.0/doc/source/index.rst --- old/git-review-1.27.0/doc/source/index.rst 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/doc/source/index.rst 2019-04-08 22:07:09.000000000 +0200 @@ -2,7 +2,7 @@ git-review ============ -``git-review`` is a tool that helps submitting git branches to gerrit +``git-review`` is a tool that helps submitting git branches to Gerrit for review. .. toctree:: @@ -12,12 +12,3 @@ usage developing releasenotes - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/doc/source/installation.rst new/git-review-1.28.0/doc/source/installation.rst --- old/git-review-1.27.0/doc/source/installation.rst 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/doc/source/installation.rst 2019-04-08 22:07:09.000000000 +0200 @@ -5,16 +5,15 @@ Installing git-review ===================== -``git-review`` can be often be installed via system packages, ``pypi`` -releases or other platform-specific methods. See -`<https://www.mediawiki.org/wiki/Gerrit/git-review>`__ for platform -information. +``git-review`` can be installed from PyPI or system packages. To install from +PyPI, run:: -For assistance installing pacakges from ``pypi`` on your OS check out -`get-pip.py <https://pip.pypa.io/en/stable/installing/>`__. + pip install git-review -For installation from source simply add ``git-review`` to your $PATH -after installing the dependencies listed in requirements.txt +Alternatively, refer to the `MediaWiki Guide`__ for information on installing +from system packages. + +__ https://www.mediawiki.org/wiki/Gerrit/git-review .. note:: ``git-review`` requires git version 1.8 or greater. @@ -28,22 +27,24 @@ modifying the local install with `win-unicode-console <https://github.com/Drekin/win-unicode-console>`__ may also help. + Setup ===== -By default, git-review will look for a remote named 'gerrit' for working +By default, git-review will look for a remote named ``gerrit`` for working with Gerrit. If the remote exists, git-review will submit the current -branch to HEAD:refs/for/master at that remote. +branch to ``HEAD:refs/for/master`` at that remote. If the Gerrit remote does not exist, git-review looks for a file -called .gitreview at the root of the repository with information about -the gerrit remote. Assuming that file is present, git-review should +called ``.gitreview`` at the root of the repository with information about +the Gerrit remote. Assuming that file is present, git-review should be able to automatically configure your repository the first time it is run. The name of the Gerrit remote is configurable; see the configuration section below. + .gitreview file format ====================== @@ -55,10 +56,10 @@ project=openstack-infra/git-review.git defaultbranch=master -Required values: host, project +Required values: ``host``, ``project`` -Optional values: port (default: 29418), defaultbranch (default: master), -defaultremote (default: gerrit). +Optional values: ``port`` (default: ``29418``), ``defaultbranch`` (default: +``master``), ``defaultremote`` (default: ``gerrit``). **Notes** @@ -68,18 +69,20 @@ of the variable. * Upon first run, git-review will create a remote for working with Gerrit, - if it does not already exist. By default, the remote name is 'gerrit', - but this can be overridden with the 'defaultremote' configuration + if it does not already exist. By default, the remote name is ``gerrit``, + but this can be overridden with the ``defaultremote`` configuration option. * You can specify different values to be used as defaults in - ~/.config/git-review/git-review.conf or /etc/git-review/git-review.conf. + ``~/.config/git-review/git-review.conf`` or + ``/etc/git-review/git-review.conf``. -* Git-review will query git credential system for gerrit user/password when +* git-review will query git credential system for Gerrit user/password when authentication failed over http(s). Unlike git, git-review does not persist - gerrit user/password in git credential system for security purposes and git + Gerrit user/password in git credential system for security purposes and git credential system configuration stays under user responsibility. + Hooks ===== @@ -87,13 +90,12 @@ actions. This is done in the same spirit as the classic hooks in git. There are two types of hooks, a global one which is stored in -~/.config/git-review/hooks/ and one local to the repository stored in -.git/hooks/ with the other git hook scripts. +``~/.config/git-review/hooks/`` and one local to the repository stored in +``.git/hooks/`` with the other git hook scripts. **The script needs be executable before getting executed** -The name of the script is $action-review where action can be -: +The name of the script is $action-review where action can be: * pre - run at first before doing anything. @@ -101,5 +103,5 @@ * draft - run when in draft mode. -if the script returns with an exit status different than zero, -git-review will exit with the a custom shell exit code 71. +If the script returns with an exit status different than zero, git-review will +exit with the custom shell exit code ``71``. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/doc/source/usage.rst new/git-review-1.28.0/doc/source/usage.rst --- old/git-review-1.27.0/doc/source/usage.rst 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/doc/source/usage.rst 2019-04-08 22:07:09.000000000 +0200 @@ -53,3 +53,15 @@ If you just want to do the commit message and remote setup steps:: git review -s + + +.. note:: + + If using multiple SSH keys (identities) or SSH keys with passphrases, you + may wish to use a tool like `ssh-agent`__, `Gnome Seahorse`__ or `KDE + KWallet`__ to avoid manual SSH configuration or frequent passphrase + requests. + + __ https://www.ssh.com/ssh/agent + __ https://wiki.gnome.org/Apps/Seahorse + __ https://userbase.kde.org/KDE_Wallet_Manager diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/git_review/cmd.py new/git-review-1.28.0/git_review/cmd.py --- old/git-review-1.27.0/git_review/cmd.py 2018-09-19 19:59:35.000000000 +0200 +++ new/git-review-1.28.0/git_review/cmd.py 2019-04-08 22:07:09.000000000 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +# -*- coding: utf-8 -*- from __future__ import print_function COPYRIGHT = """\ @@ -25,30 +25,19 @@ import os import re import shlex +import six import subprocess import sys import textwrap import pkg_resources import requests +from six.moves import configparser +from six.moves import input as do_input +from six.moves.urllib.parse import urlencode +from six.moves.urllib.parse import urljoin +from six.moves.urllib.parse import urlparse -if sys.version < '3': - import ConfigParser - import urllib - import urlparse - urlencode = urllib.urlencode - urljoin = urlparse.urljoin - urlparse = urlparse.urlparse - do_input = raw_input -else: - import configparser as ConfigParser - - import urllib.parse - import urllib.request - urlencode = urllib.parse.urlencode - urljoin = urllib.parse.urljoin - urlparse = urllib.parse.urlparse - do_input = input VERBOSE = False UPDATE = False @@ -76,7 +65,7 @@ class GitReviewException(Exception): - EXIT_CODE = 127 + EXIT_CODE = 1 class CommandFailed(GitReviewException): @@ -134,7 +123,7 @@ print(datetime.datetime.now(), "Running:", " ".join(argv)) if len(argv) == 1: # for python2 compatibility with shlex - if sys.version_info < (3,) and isinstance(argv[0], unicode): + if sys.version_info < (3,) and isinstance(argv[0], six.text_type): argv = shlex.split(argv[0].encode('utf-8')) else: argv = shlex.split(str(argv[0])) @@ -163,7 +152,7 @@ klazz should be derived from CommandFailed """ (rc, output) = run_command_status(*argv, **env) - if rc != 0: + if rc: raise klazz(rc, output, argv, env) return output @@ -254,7 +243,7 @@ returns.append((status, output, fpath)) for (status, output, path) in returns: - if status is not None and status != 0: + if status: raise CustomScriptException(status, output, [path], {}) elif output and VERBOSE: print("script %s output is:" % (path)) @@ -272,12 +261,15 @@ try: result = run_command_exc(GitConfigException, *cmd).strip() if VERBOSE: - print(datetime.datetime.now(), "result:", result) + print(datetime.datetime.now(), "... %s.%s = %s" + % (section, option, result)) return result except GitConfigException as exc: if exc.rc == 1: - if VERBOSE: - print(datetime.datetime.now(), "using default:", default) + if VERBOSE and default is not None: + print(datetime.datetime.now(), + "... nothing in git config, returning func parameter:", + default) return default raise @@ -300,9 +292,16 @@ self.config.update(load_config_file(filename)) def __getitem__(self, key): + """Let 'git config --get' override every Config['key'] access""" value = git_config_get_value('gitreview', key) if value is None: value = self.config[key] + # "--verbose" doesn't trace *early* invocations; for that you + # must change the value at the top of this file (*and* pass + # --verbose) + if VERBOSE: + print(datetime.datetime.now(), + "Config['%s'] = %s " % (key, value)) return value @@ -338,10 +337,10 @@ else: (hostname, username, port, project_name) = \ parse_gerrit_ssh_params_from_git_url(remote_url) - if username is None: - userhost = hostname - else: + if username: userhost = "%s@%s" % (username, hostname) + else: + userhost = hostname # OS independent target file scp_target_file = target_file.replace(os.sep, "/") cmd = ["scp", userhost + ":hooks/commit-msg", scp_target_file] @@ -376,10 +375,10 @@ if port is None and scheme == 'ssh': port = 29418 hostport = '%s:%s' % (hostname, port) if port else hostname - if username is None: - return "%s://%s/%s" % (scheme, hostport, project) - else: + if username: return "%s://%s@%s/%s" % (scheme, username, hostport, project) + else: + return "%s://%s/%s" % (scheme, hostport, project) def add_remote(scheme, hostname, port, project, remote, usepushurl): @@ -413,7 +412,7 @@ print("\t%s" % remote_url) (status, remote_output) = run_command_status(cmd) - if status != 0: + if status: raise CommandFailed(status, remote_output, cmd, {}) if asked_for_username: @@ -526,7 +525,7 @@ hostname = parsed_url.path[2:].split("/")[0] if "@" in hostname: - (username, hostname) = hostname.split("@") + (username, _, hostname) = hostname.rpartition("@") if ":" in hostname: (hostname, port) = hostname.split(":") @@ -704,7 +703,7 @@ def load_config_file(config_file): """Load configuration options from a file.""" - configParser = ConfigParser.ConfigParser() + configParser = configparser.ConfigParser() configParser.read(config_file) options = { 'scheme': 'scheme', @@ -806,8 +805,8 @@ printwrap("Please set the push-url on your origin remote to the " "location of your gerrit server and try again") else: - printwrap("Please manually create a remote " - "named \"%s\" and try again." % remote) + printwrap("Please manually create a remote named \"%s\" or " + "rename the default one and try again." % remote) sys.exit(1) # Gerrit remote not present, try to add it @@ -939,61 +938,25 @@ sys.exit(1) -def use_topic(why, topic): - """Inform the user about why a particular topic has been selected.""" - if VERBOSE: - print(why % ('"%s"' % topic,)) - return topic - - def get_topic(target_branch): - branch_name = get_branch_name(target_branch) branch_parts = branch_name.split("/") if len(branch_parts) >= 3 and branch_parts[0] == "review": - return use_topic("Using change number %s " - "for the topic of the change submitted", - "/".join(branch_parts[2:])) - - preferred_log_format = "%B" - log_output = run_command("git log --pretty='" + preferred_log_format + - "' HEAD^1..HEAD") - if log_output == preferred_log_format: - # The %B format specifier is supported starting at Git v1.7.2. If it's - # not supported, we'll just get back '%B', so we try something else. - # The downside of %s is that it removes newlines in the subject. - log_output = run_command("git log --pretty='%s%n%b' HEAD^1..HEAD") - bug_re = r'''(?x) # verbose regexp - \b([Bb]ug|[Ll][Pp]) # bug or lp - [ \t\f\v]* # don't want to match newline - [:]? # separator if needed - [ \t\f\v]* # don't want to match newline - [#]? # if needed - [ \t\f\v]* # don't want to match newline - (\d+) # bug number''' - - match = re.search(bug_re, log_output) - if match is not None: - return use_topic("Using bug number %s " - "for the topic of the change submitted", - "bug/%s" % match.group(2)) - - bp_re = r'''(?x) # verbose regexp - \b([Bb]lue[Pp]rint|[Bb][Pp]) # a blueprint or bp - [ \t\f\v]* # don't want to match newline - [#:]? # separator if needed - [ \t\f\v]* # don't want to match newline - ([0-9a-zA-Z-_]+) # any identifier or number''' - match = re.search(bp_re, log_output) - if match is not None: - return use_topic("Using blueprint number %s " - "for the topic of the change submitted", - "bp/%s" % match.group(2)) - - return use_topic("Using local branch name %s " - "for the topic of the change submitted", - branch_name) + # We don't want to set the review number as the topic + if branch_parts[2].isdigit(): + return + + topic = "/".join(branch_parts[2:]) + if VERBOSE: + print("Using change number %s for the topic of the change " + "submitted" % topic) + return topic + + if VERBOSE: + print("Using local branch name %s for the topic of the change " + "submitted" % branch_name) + return branch_name class CannotQueryOpenChangesets(CommandFailed): @@ -1232,7 +1195,7 @@ print("Downloading %s from gerrit" % refspec) run_command_exc(PatchSetGitFetchFailed, - "git", "fetch", remote, refspec) + "git", "fetch", remote_url, refspec) return branch_name, remote_branch @@ -1737,11 +1700,21 @@ def main(): + # workaround for avoiding UnicodeEncodeError on print() with older python + if sys.version_info[0] < 3: + # without reload print would fail even if sys.stdin.encoding + # would report utf-8 + # see: https://stackoverflow.com/a/23847316/99834 + stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr + reload(sys) + sys.stdin, sys.stdout, sys.stderr = stdin, stdout, stderr + sys.setdefaultencoding(os.environ.get('PYTHONIOENCODING', 'utf-8')) + try: _main() except GitReviewException as e: print(e) - sys.exit(getattr(e, 'EXIT_CODE', -1)) + sys.exit(e.EXIT_CODE) if __name__ == "__main__": diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/git_review/tests/__init__.py new/git-review-1.28.0/git_review/tests/__init__.py --- old/git-review-1.27.0/git_review/tests/__init__.py 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/git_review/tests/__init__.py 2019-04-08 22:07:09.000000000 +0200 @@ -153,7 +153,7 @@ os.makedirs(self._dir('gsite', 'etc')) # create SSH host key host_key_file = self._dir('gsite', 'etc', 'ssh_host_rsa_key') - utils.run_cmd('ssh-keygen', '-t', 'rsa', '-b', '4096', + utils.run_cmd('ssh-keygen', '-t', 'rsa', '-b', '4096', '-m', 'PEM', '-f', host_key_file, '-N', '') print("Creating a new golden site of version " + GOLDEN_SITE_VER) @@ -171,7 +171,7 @@ # create SSH public key key_file = self._dir('gsite', 'test_ssh_key') - utils.run_cmd('ssh-keygen', '-t', 'rsa', '-b', '4096', + utils.run_cmd('ssh-keygen', '-t', 'rsa', '-b', '4096', '-m', 'PEM', '-f', key_file, '-N', '') with open(key_file + '.pub', 'rb') as pub_key_file: pub_key = pub_key_file.read() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/git_review/tests/test_git_review.py new/git-review-1.28.0/git_review/tests/test_git_review.py --- old/git-review-1.27.0/git_review/tests/test_git_review.py 2018-09-19 19:59:35.000000000 +0200 +++ new/git-review-1.28.0/git_review/tests/test_git_review.py 2019-04-08 22:07:09.000000000 +0200 @@ -18,6 +18,7 @@ import json import os import shutil +import testtools from git_review import tests from git_review.tests import utils @@ -286,9 +287,10 @@ br_out = self._run_git('checkout', '-b', 'test_branch', 'origin/maint') - expected_track = 'Branch test_branch set up to track remote' + \ - ' branch maint from origin.' - self.assertIn(expected_track, br_out) + expected_track = ".*\nBranch '?test_branch'? set up to track remote" + \ + " branch '?maint'? from '?origin'?." + track_matcher = testtools.matchers.MatchesRegex(expected_track) + self.assertThat(br_out, track_matcher) branches = self._run_git('branch', '-a') expected_branch = '* test_branch' observed = branches.split('\n') @@ -383,98 +385,27 @@ finally: os.environ.update(LANG=lang_env) + def test_no_topic(self): + """Test on change with no topic. + + This will be checked out as 'review/{owner}/{ID}'. We don't want to set + the topic to '{ID}'. + """ + self._run_git_review('-s') + curr_branch = self._run_git('rev-parse', '--abbrev-ref', 'HEAD') + self._run_git('checkout', '-b', 'review/johndoe/123456') + self._simple_change('test file modified', 'derp derp derp') + self._assert_branch_would_be(curr_branch) + def test_git_review_t(self): self._run_git_review('-s') self._simple_change('test file modified', 'commit message for bug 654') self._assert_branch_would_be('master%topic=zat', extra_args=['-t', 'zat']) - def test_bug_topic(self): - self._run_git_review('-s') - self._simple_change('a change', 'new change for bug 123') - self._assert_branch_would_be('master%topic=bug/123') - - def test_bug_topic_newline(self): - self._run_git_review('-s') - self._simple_change('a change', 'new change not for bug\n\n123') - self._assert_branch_would_be('master') - - def test_bp_topic(self): - self._run_git_review('-s') - self._simple_change('a change', 'new change for blueprint asdf') - self._assert_branch_would_be('master%topic=bp/asdf') - - def test_bp_topic_newline(self): - self._run_git_review('-s') - self._simple_change('a change', 'new change not for blueprint\n\nasdf') - self._assert_branch_would_be('master') - - def test_author_name_topic_bp(self): - old_author = None - if 'GIT_AUTHOR_NAME' in os.environ: - old_author = os.environ['GIT_AUTHOR_NAME'] - try: - os.environ['GIT_AUTHOR_NAME'] = 'BPNAME' - self._run_git_review('-s') - self._simple_change('a change', - 'new change 1 with name but no topic') - self._assert_branch_would_be('master') - finally: - if old_author: - os.environ['GIT_AUTHOR_NAME'] = old_author - else: - del os.environ['GIT_AUTHOR_NAME'] - - def test_author_email_topic_bp(self): - old_author = None - if 'GIT_AUTHOR_EMAIL' in os.environ: - old_author = os.environ['GIT_AUTHOR_EMAIL'] - try: - os.environ['GIT_AUTHOR_EMAIL'] = 'bpemail@example.com' - self._run_git_review('-s') - self._simple_change('a change', - 'new change 1 with email but no topic') - self._assert_branch_would_be('master') - finally: - if old_author: - os.environ['GIT_AUTHOR_EMAIL'] = old_author - else: - del os.environ['GIT_AUTHOR_EMAIL'] - - def test_author_name_topic_bug(self): - old_author = None - if 'GIT_AUTHOR_NAME' in os.environ: - old_author = os.environ['GIT_AUTHOR_NAME'] - try: - os.environ['GIT_AUTHOR_NAME'] = 'Bug: #1234' - self._run_git_review('-s') - self._simple_change('a change', - 'new change 2 with name but no topic') - self._assert_branch_would_be('master') - finally: - if old_author: - os.environ['GIT_AUTHOR_NAME'] = old_author - else: - del os.environ['GIT_AUTHOR_NAME'] - - def test_author_email_topic_bug(self): - old_author = None - if 'GIT_AUTHOR_EMAIL' in os.environ: - old_author = os.environ['GIT_AUTHOR_EMAIL'] - try: - os.environ['GIT_AUTHOR_EMAIL'] = 'bug5678@example.com' - self._run_git_review('-s') - self._simple_change('a change', - 'new change 2 with email but no topic') - self._assert_branch_would_be('master') - finally: - if old_author: - os.environ['GIT_AUTHOR_EMAIL'] = old_author - else: - del os.environ['GIT_AUTHOR_EMAIL'] - def test_git_review_T(self): self._run_git_review('-s') + self._run_git('checkout', '-b', 'bug/456') self._simple_change('test file modified', 'commit message for bug 456') self._assert_branch_would_be('master%topic=bug/456') self._assert_branch_would_be('master', extra_args=['-T']) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/git_review/tests/test_unit.py new/git-review-1.28.0/git_review/tests/test_unit.py --- old/git-review-1.27.0/git_review/tests/test_unit.py 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/git_review/tests/test_unit.py 2019-04-08 22:07:09.000000000 +0200 @@ -104,6 +104,17 @@ self.run_cmd_patcher.stop() super(GitReviewConsole, self).tearDown() + @mock.patch('git_review.cmd.get_version', + side_effect=cmd.GitReviewException(u"simple-toπ㌀c")) + def test_print_exception_with_unicode(self, exists_mock): + + try: + with mock.patch('sys.argv', ['git-review', '--version']): + with self.assertRaisesRegexp(SystemExit, '1'): + cmd.main() + except Exception as e: + self.fail('Exception not expected: %s' % e) + @mock.patch('git_review.cmd.query_reviews') @mock.patch('git_review.cmd.get_remote_url', mock.MagicMock) @mock.patch('git_review.cmd._has_color', False) @@ -412,3 +423,42 @@ 'https://review.openstack.org/c/org/project/+/12345'] ) self.assertEqual('12345', args.cid) + + +class RepoUrlParsingTest(testtools.TestCase): + """Test Git URL parsing""" + + def test_ssh_openstack(self): + self.assertEqual( + cmd.parse_gerrit_ssh_params_from_git_url( + 'ssh://someone@review.openstack.org:29418/x/y'), + ('review.openstack.org', 'someone', '29418', + 'x/y')) + + def test_ssh_no_user_no_port(self): + self.assertEqual( + cmd.parse_gerrit_ssh_params_from_git_url( + 'ssh://review.openstack.org/openstack-infra/git-review'), + ('review.openstack.org', None, None, + 'openstack-infra/git-review')) + + def test_ssh_at_sign(self): + self.assertEqual( + cmd.parse_gerrit_ssh_params_from_git_url( + 'ssh://someone@example.org@review.openstack.org:29418/x/y'), + ('review.openstack.org', 'someone@example.org', '29418', + 'x/y')) + + def test_ssh_at_signs_excessive(self): + self.assertEqual( + cmd.parse_gerrit_ssh_params_from_git_url( + 'ssh://x@y@example.org@review.openstack.org:29418/x/y'), + ('review.openstack.org', 'x@y@example.org', '29418', + 'x/y')) + + def test_ssh_at_sign_escaped(self): + self.assertEqual( + cmd.parse_gerrit_ssh_params_from_git_url( + r'ssh://someone%40example.org@review.openstack.org:29418/x/y'), + ('review.openstack.org', r'someone%40example.org', '29418', + 'x/y')) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/git_review.egg-info/PKG-INFO new/git-review-1.28.0/git_review.egg-info/PKG-INFO --- old/git-review-1.27.0/git_review.egg-info/PKG-INFO 2018-09-19 20:00:55.000000000 +0200 +++ new/git-review-1.28.0/git_review.egg-info/PKG-INFO 2019-04-08 22:08:44.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: git-review -Version: 1.27.0 +Version: 1.28.0 Summary: Tool to submit code to Gerrit Home-page: http://docs.openstack.org/infra/git-review/ Author: OpenStack diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/git_review.egg-info/SOURCES.txt new/git-review-1.28.0/git_review.egg-info/SOURCES.txt --- old/git-review-1.27.0/git_review.egg-info/SOURCES.txt 2018-09-19 20:00:56.000000000 +0200 +++ new/git-review-1.28.0/git_review.egg-info/SOURCES.txt 2019-04-08 22:08:44.000000000 +0200 @@ -1,5 +1,5 @@ .mailmap -.testr.conf +.stestr.conf AUTHORS CONTRIBUTING.rst ChangeLog @@ -38,4 +38,8 @@ git_review/tests/test_git_review.py git_review/tests/test_unit.py git_review/tests/utils.py -releasenotes/notes/missed-notes-f903719767e0a0ce.yaml \ No newline at end of file +releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml +releasenotes/notes/fix-usepushurl-c4a234689d808ece.yaml +releasenotes/notes/ignore-topic-for-master-patches-9ba01c0762d3df65.yaml +releasenotes/notes/missed-notes-f903719767e0a0ce.yaml +releasenotes/notes/remove-automatic-branch-naming-8e3e2f6487637b86.yaml \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/git_review.egg-info/pbr.json new/git-review-1.28.0/git_review.egg-info/pbr.json --- old/git-review-1.27.0/git_review.egg-info/pbr.json 2018-09-19 20:00:55.000000000 +0200 +++ new/git-review-1.28.0/git_review.egg-info/pbr.json 2019-04-08 22:08:44.000000000 +0200 @@ -1 +1 @@ -{"git_version": "185fb8d", "is_release": true} \ No newline at end of file +{"git_version": "853f3bf", "is_release": true} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/git_review.egg-info/requires.txt new/git-review-1.28.0/git_review.egg-info/requires.txt --- old/git-review-1.27.0/git_review.egg-info/requires.txt 2018-09-19 20:00:55.000000000 +0200 +++ new/git-review-1.28.0/git_review.egg-info/requires.txt 2019-04-08 22:08:44.000000000 +0200 @@ -1 +1,2 @@ requests>=1.1 +six diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml new/git-review-1.28.0/releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml --- old/git-review-1.27.0/releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/git-review-1.28.0/releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml 2019-04-08 22:07:09.000000000 +0200 @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes ``gitreview`` process exit code to align with general + UNIX process exit code conventions. Specifically, default exit + code changed to ``1`` which stands for "general error". diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/releasenotes/notes/fix-usepushurl-c4a234689d808ece.yaml new/git-review-1.28.0/releasenotes/notes/fix-usepushurl-c4a234689d808ece.yaml --- old/git-review-1.27.0/releasenotes/notes/fix-usepushurl-c4a234689d808ece.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/git-review-1.28.0/releasenotes/notes/fix-usepushurl-c4a234689d808ece.yaml 2019-04-08 22:07:09.000000000 +0200 @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixed ``usepushurl`` to work when a read-only mirror being used as + ``origin`` does not contain ``refs/changes`` from gerrit. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/releasenotes/notes/ignore-topic-for-master-patches-9ba01c0762d3df65.yaml new/git-review-1.28.0/releasenotes/notes/ignore-topic-for-master-patches-9ba01c0762d3df65.yaml --- old/git-review-1.27.0/releasenotes/notes/ignore-topic-for-master-patches-9ba01c0762d3df65.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/git-review-1.28.0/releasenotes/notes/ignore-topic-for-master-patches-9ba01c0762d3df65.yaml 2019-04-08 22:07:09.000000000 +0200 @@ -0,0 +1,6 @@ +--- +fixes: + - | + If a patch has no topic, downloading it will result in a topic of + ``review/{owner}/{ID}``. Previously, submitting this would then set the + topic to ``{ID}``. This was incorrect behavior and is now resolved. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/releasenotes/notes/remove-automatic-branch-naming-8e3e2f6487637b86.yaml new/git-review-1.28.0/releasenotes/notes/remove-automatic-branch-naming-8e3e2f6487637b86.yaml --- old/git-review-1.27.0/releasenotes/notes/remove-automatic-branch-naming-8e3e2f6487637b86.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/git-review-1.28.0/releasenotes/notes/remove-automatic-branch-naming-8e3e2f6487637b86.yaml 2019-04-08 22:07:09.000000000 +0200 @@ -0,0 +1,10 @@ +--- +upgrade: + - | + Support for auto-configuration of topic names based on the presence of + keywords in the commit message is removed. Previously, keywords such as + ``bug``, ``bp`` or ``lp`` followed by a number would result in branch + names containing the associated number, e.g. ``bug/123``. This feature + was OpenStack specific, was a frequent source of bugs and clearly wasn't + being used that often, given that StoryBoard is a thing now and no one had + updated this feature to handle that metadata. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/requirements.txt new/git-review-1.28.0/requirements.txt --- old/git-review-1.27.0/requirements.txt 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/requirements.txt 2019-04-08 22:07:09.000000000 +0200 @@ -1 +1,2 @@ requests>=1.1 +six diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/test-requirements.txt new/git-review-1.28.0/test-requirements.txt --- old/git-review-1.27.0/test-requirements.txt 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/test-requirements.txt 2019-04-08 22:07:09.000000000 +0200 @@ -1,5 +1,5 @@ hacking>=0.10.0,<0.11 mock fixtures>=0.3.14 -testrepository>=0.0.18 +stestr>=2.2.0 testtools>=0.9.34 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-review-1.27.0/tox.ini new/git-review-1.28.0/tox.ini --- old/git-review-1.27.0/tox.ini 2018-09-19 19:59:23.000000000 +0200 +++ new/git-review-1.28.0/tox.ini 2019-04-08 22:07:09.000000000 +0200 @@ -1,30 +1,33 @@ [tox] -envlist = pep8,docs,py27,py37,py36,py35,py34 +envlist = pep8,docs,py27,py3{4,5,6,7} [testenv] -install_command = pip install -U {opts} {packages} -setenv = - VIRTUAL_ENV={envdir} - +# See "testing behind a proxy" +# @ https://review.openstack.org/#/q/I764ed51314c8e2d0572d1f0 +passenv = + http_proxy + https_proxy + # avoids potential slip-over of java 1.9 which breaks Gerrit, without it + # Gerrit may start with incompatible java version. + JAVA_HOME + # uncomment to allow custom java options to be added + # _JAVA_OPTIONS + TERM commands = python -m git_review.tests.check_test_id_hashes discover --list python -m git_review.tests.prepare - python setup.py testr --slowest --testr-args='--concurrency=2 {posargs}' - + stestr run --color {posargs} deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt [testenv:pep8] commands = flake8 -[testenv:sdist] -commands = python setup.py sdist {posargs} - [testenv:docs] deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/doc/requirements.txt + -r{toxinidir}/requirements.txt + -r{toxinidir}/doc/requirements.txt commands = sphinx-build -W -d doc/build/doctrees -b html doc/source/ doc/build/html @@ -34,4 +37,4 @@ [flake8] ignore = E125,H202,H405,H904 show-source = True -exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build +exclude = .venv,.git,.tox,dist,doc,releasenotes,*lib/python*,*egg,build
participants (1)
-
root