trivial: Update to hacking 2.x
Fixes an issue we're seeing in the python3-based gate plus some other random things. Change-Id: I417c0a7669090ee3419c406024f6f3e3289b4c4b Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
dba41b2532
commit
ddbd0ba1d9
@ -1,23 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2011-2020 OpenStack LLC.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
COPYRIGHT = """\
|
||||
Copyright (C) 2011-2012 OpenStack LLC.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied.
|
||||
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License."""
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import getpass
|
||||
@ -48,6 +46,24 @@ USER_CONFIG = os.path.join(CONFIGDIR, "git-review.conf")
|
||||
DEFAULTS = dict(scheme='ssh', hostname=False, port=None, project=False,
|
||||
branch='master', remote="gerrit", rebase="1",
|
||||
track="0", usepushurl="0")
|
||||
COPYRIGHT = """\
|
||||
Copyright (C) 2011-2020 OpenStack LLC.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied.
|
||||
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
|
||||
_branch_name = None
|
||||
_has_color = None
|
||||
@ -469,8 +485,8 @@ def alias_url(url, rewrite_push):
|
||||
# there is a longer insteadOf alias.
|
||||
longest = None
|
||||
for alias in rewrites:
|
||||
if (url.startswith(alias)
|
||||
and (longest is None or len(longest) < len(alias))):
|
||||
if url.startswith(alias) and (
|
||||
longest is None or len(longest) < len(alias)):
|
||||
longest = alias
|
||||
|
||||
if longest:
|
||||
@ -1183,7 +1199,7 @@ def fetch_review(review, masterbranch, remote, project):
|
||||
except KeyError:
|
||||
topic = review
|
||||
try:
|
||||
author = re.sub('\W+', '_', review_info['owner']['name']).lower()
|
||||
author = re.sub(r'\W+', '_', review_info['owner']['name']).lower()
|
||||
except KeyError:
|
||||
author = 'unknown'
|
||||
remote_branch = review_info['branch']
|
||||
@ -1216,7 +1232,7 @@ def checkout_review(branch_name, remote, remote_branch):
|
||||
branch_name)
|
||||
|
||||
except CheckoutNewBranchFailed as e:
|
||||
if re.search("already exists\.?", e.output):
|
||||
if re.search(r"already exists\.?", e.output):
|
||||
print("Branch %s already exists - reusing" % branch_name)
|
||||
track_remote, track_branch = parse_tracking(
|
||||
ref='refs/heads/' + branch_name)
|
||||
@ -1389,7 +1405,14 @@ class _DownloadFlag(argparse.Action):
|
||||
def _main():
|
||||
usage = "git review [OPTIONS] ... [BRANCH]"
|
||||
|
||||
parser = argparse.ArgumentParser(usage=usage, description=COPYRIGHT)
|
||||
description = """\
|
||||
A git command for submitting branches to Gerrit.
|
||||
|
||||
git-review is a tool that helps submitting git branches to gerrit for
|
||||
review.
|
||||
"""
|
||||
|
||||
parser = argparse.ArgumentParser(usage=usage, description=description)
|
||||
|
||||
topic_arg_group = parser.add_mutually_exclusive_group()
|
||||
topic_arg_group.add_argument("-t", "--topic", dest="topic",
|
||||
@ -1707,7 +1730,7 @@ def main():
|
||||
# would report utf-8
|
||||
# see: https://stackoverflow.com/a/23847316/99834
|
||||
stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr
|
||||
reload(sys)
|
||||
reload(sys) # noqa
|
||||
sys.stdin, sys.stdout, sys.stderr = stdin, stdout, stderr
|
||||
sys.setdefaultencoding(os.environ.get('PYTHONIOENCODING', 'utf-8'))
|
||||
|
||||
|
@ -20,6 +20,13 @@ import stat
|
||||
import struct
|
||||
import sys
|
||||
|
||||
import fixtures
|
||||
import requests
|
||||
import testtools
|
||||
from testtools import content
|
||||
|
||||
from git_review.tests import utils
|
||||
|
||||
if sys.version < '3':
|
||||
import urllib
|
||||
import urlparse
|
||||
@ -29,12 +36,6 @@ else:
|
||||
import urllib.request
|
||||
urlparse = urllib.parse.urlparse
|
||||
|
||||
import fixtures
|
||||
import requests
|
||||
import testtools
|
||||
from testtools import content
|
||||
|
||||
from git_review.tests import utils
|
||||
|
||||
WAR_URL = 'http://tarballs.openstack.org/' \
|
||||
'ci/gerrit/gerrit-v2.11.4.13.cb9800e.war'
|
||||
|
@ -53,5 +53,6 @@ def main(argv):
|
||||
)
|
||||
return 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv))
|
||||
|
@ -22,5 +22,6 @@ def main():
|
||||
helpers.ensure_gerrit_war()
|
||||
helpers.init_gerrit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -287,8 +287,8 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
|
||||
|
||||
br_out = self._run_git('checkout',
|
||||
'-b', 'test_branch', 'origin/maint')
|
||||
expected_track = ".*\nBranch '?test_branch'? set up to track remote" + \
|
||||
" branch '?maint'? from '?origin'?."
|
||||
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')
|
||||
|
@ -18,6 +18,22 @@ import subprocess
|
||||
import traceback
|
||||
|
||||
|
||||
GERRIT_CONF_TMPL = """
|
||||
[gerrit]
|
||||
basePath = git
|
||||
canonicalWebUrl = http://nonexistent/
|
||||
[database]
|
||||
type = h2
|
||||
database = db/ReviewDB
|
||||
[auth]
|
||||
type = DEVELOPMENT_BECOME_ANY_ACCOUNT
|
||||
[sshd]
|
||||
listenAddress = %s:%s
|
||||
[httpd]
|
||||
listenUrl = http://%s:%s/
|
||||
"""
|
||||
|
||||
|
||||
def run_cmd(*args, **kwargs):
|
||||
"""Run command and check the return code."""
|
||||
preexec_fn = None
|
||||
@ -64,21 +80,6 @@ def write_to_file(path, content):
|
||||
with open(path, 'wb') as file_:
|
||||
file_.write(content)
|
||||
|
||||
GERRIT_CONF_TMPL = """
|
||||
[gerrit]
|
||||
basePath = git
|
||||
canonicalWebUrl = http://nonexistent/
|
||||
[database]
|
||||
type = h2
|
||||
database = db/ReviewDB
|
||||
[auth]
|
||||
type = DEVELOPMENT_BECOME_ANY_ACCOUNT
|
||||
[sshd]
|
||||
listenAddress = %s:%s
|
||||
[httpd]
|
||||
listenUrl = http://%s:%s/
|
||||
"""
|
||||
|
||||
|
||||
def get_gerrit_conf(ssh_addr, ssh_port, http_addr, http_port):
|
||||
return GERRIT_CONF_TMPL % (ssh_addr, ssh_port, http_addr, http_port)
|
||||
|
@ -1,4 +1,4 @@
|
||||
hacking>=0.10.0,<0.11
|
||||
hacking>=2.0.0,<2.1.0
|
||||
mock
|
||||
fixtures>=0.3.14
|
||||
stestr>=2.2.0
|
||||
|
Loading…
Reference in New Issue
Block a user