513 Commits

Author SHA1 Message Date
Sorin Sbarnea
514958d3f3 Switch from testrepository to stestr
Adopts use of newer stestr for running the test suite.

Passing TERM is needed or stestr will ignore the --color option when
run under tox.

Change-Id: Id2d4ce36cdfedd5a847e0428854753d2cf4140ee
2019-02-12 09:58:46 +00:00
Sorin Sbarnea
e535d4467e Allow user to control Java version used by tox
This allows user to define JAVA_HOME in order to control which version
of Java will be used by Gerrit during tox testing.

Avoid Gerrit startup failure due to use of wrong version of Java,
even if `java -version` would have reported the right version.

On systems with multiple versions of Java 8/9/10 it was impossible to
run tox because the launcher would have always picked the latest
version which is clearly not compatible with Gerrit war archive used
for testing.

In the future we will start using a gerrit container for testing and
avoid dependency on local Java version.

Change-Id: I05b6f7125393a009e1fdcf556b17df158c10eea0
2019-01-29 17:36:28 +00:00
Zuul
afa54af210 Merge "Fix wrong and misleading "using default: None" in --verbose mode" 2018-12-27 11:25:24 +00:00
Marc Herbert
d5f02d61cb Fix wrong and misleading "using default: None" in --verbose mode
When something is not found in git config, the --verbose option logs the
wrong value "None", example:

2018-12-12  Running: git config --get gitreview.branch
2018-12-12  using default: None
2018-12-12  Running: git config --get gitreview.scheme
2018-12-12  using default: None
2018-12-12  Running: git config --get remote.gerrit.pushurl
2018-12-12  using default: None
2018-12-12  Running: git config --get remote.gerrit.url
2018-12-12  result: ssh://marc@review.openstack.org:29418/openstack-infra/git-review

From a --verbose user perspective this is plain wrong for (at least) all the
options defined in the DEFAULTS list.

Change --verbose message to look like this instead:

2018-12-12  Running: git config --get gitreview.branch
2018-12-12  Config['branch'] = master
2018-12-12  Running: git config --get gitreview.scheme
2018-12-12  Config['scheme'] = ssh
2018-12-12  Running: git config --get remote.gerrit.pushurl
2018-12-12  Running: git config --get remote.gerrit.url
2018-12-12  ... remote.gerrit.url = ssh://marc@review.openstack.org:29418/openstack-infra/git-review

If git_config_get_value('new_option',... ) is ever invoked in the future
with a not None, default="fubar" parameter then --verbose will print these
lines:

2018-12-19  Running: git config --get gitreview.new_option
2018-12-19  ... nothing in git config, returning func parameter: fubar

This logging issue is especially misleading considering the many levels of
defaults and fallbacks: git config x3; .gitreview; DEFAULTS list,
git_config_get_value(default=...) parameter, options parser logic, etc.

Change-Id: I6cee46e88b90b8f11689be3875d64ec5e577f12f
2018-12-20 06:14:16 +00:00
Marc Herbert
11cf3bae58 Add hint to just "git remote rename origin gerrit" when no .gitreview
... because it Just Works with absolutely zero configuration when cloning
with ssh://

Change-Id: I7a413704c4a567e397b5bb6075677175b8997704
2018-12-18 15:36:08 -08:00
Zuul
0ffe65193a Merge "tox.ini: add passenv = http_proxy https_proxy # _JAVA_OPTIONS" 2018-12-17 21:38:06 +00:00
Zuul
3903f64de3 Merge "docs: Call out use of an agent to store SSH passwords" 2018-12-17 21:38:05 +00:00
Zuul
e1958c91f5 Merge "docs: Misc updates" 2018-12-17 21:38:03 +00:00
Zuul
a2bea9f57e Merge "test_uploads_with_nondefault_rebase: fix git screen scraping" 2018-12-14 16:21:56 +00:00
Marc Herbert
205859c788 tox.ini: add passenv = http_proxy https_proxy # _JAVA_OPTIONS
Add: 'passenv = http_proxy https_proxy' whitelist to tox.ini because there's
basically never any good reason to throw away proxy configuration.

The addition of http_proxy allows downloading
http://tarballs.openstack.org/ci/gerrit/gerrit-<version>.war
behind a proxy.

https_proxy is not needed right now but added for consistency and
"future-proofing"

_JAVA_OPTIONS is added but only as a clue and commented out by default
because it could hold non-proxy configuration which would defeat tox'
environment cleaning and introduce test variability.

This is just the tox.ini source code part of the larger
I764ed51314c8e2d0572d1f01c9792bee0a40c7e6
includes documentation of workarounds and troubleshooting tips.

Change-Id: I764ed51314c8e2d0572d1f01c9792bee0a40c7e7
2018-12-11 13:29:35 -08:00
Zuul
dfb37fa0e0 Merge "CONTRIBUTING.rst, HACKING.rst: fix broken link, minor flow updates" 2018-12-10 14:22:42 +00:00
Zuul
c746ee9bc3 Merge "tox: Remove dead settings/targets" 2018-12-10 14:07:49 +00:00
Zuul
d416d103f6 Merge "tests/__init__.py: ssh-keygen -m PEM for bouncycastle" 2018-12-10 00:17:47 +00:00
Marc Herbert
5fd2b0c32d CONTRIBUTING.rst, HACKING.rst: fix broken link, minor flow updates
Paraphrasing parts of a private email from Stephen Finucane.

Change-Id: I2b66af40ca16e311bde3b482229ef00b70dcd1f7
2018-12-07 11:23:07 -08:00
Marc Herbert
6f31931b87 test_uploads_with_nondefault_rebase: fix git screen scraping
Newer versions of git quote branch names in their output; at least git
2.16.3 does. This causes all test_uploads_with_nondefault_rebase tests to
fail like this:

testtools.matchers._impl.MismatchError:
 'Branch test_branch set up to track remote branch maint from origin.'
 not in
  u"Switched to a new branch 'test_branch'\n\
 Branch 'test_branch' set up to track remote branch 'maint' from 'origin'."

Add a testtools.matchers.MatchesRegex() to support both styles.

Change-Id: I9f1417c53de2f7d638e845f553df3bd426a4c750
2018-12-05 14:56:37 -08:00
Zuul
e9fede805a Merge "Avoid UnicodeEncodeError on python 2" 2018-12-05 11:15:49 +00:00
Marc Herbert
d41f5d7d0a tests/__init__.py: ssh-keygen -m PEM for bouncycastle
From: https://www.openssh.com/txt/release-7.8 change log:

 * ssh-keygen(1): write OpenSSH format private keys by default
   instead of using OpenSSL's PEM format. The OpenSSH format,
   supported in OpenSSH releases since 2014 and described in the
   PROTOCOL.key file in the source distribution, offers substantially
   better protection against offline password guessing and supports
   key comments in private keys. If necessary, it is possible to write
   old PEM-style keys by adding "-m PEM" to ssh-keygen's arguments
   when generating or updating a key.

This fixes all tests failing with this error:

[2018-12-04 17:46:24,130] WARN  org.apache.sshd.common.keyprovider.FileKeyPairProvider :
   Unable to read key /home/mherber2/pip/src/git-review/.gerrit/site-5123/etc/ssh_host_rsa_key
java.io.IOException: unrecognised object: OPENSSH PRIVATE KEY
	at org.bouncycastle.openssl.PEMParser.readObject(Unknown Source)
	at org.apache.sshd.common.keyprovider.FileKeyPairProvider.doLoadKey(FileKeyPairProvider.java:124)

Change-Id: Id10f9b5be928f2ba57847fa32814e9db979375f5
2018-12-04 18:12:06 -08:00
Sorin Sbarnea
d181f04353 Use six for cross python compatibility
- Fixes linting error related to undefined unicode on python3.
- Simplifies code

Change-Id: Ib40237e0fb7156b084dfdab47be69ccad09547fe
2018-11-26 19:17:28 +00:00
Sorin Sbarnea
138e9a25e3 Avoid UnicodeEncodeError on python 2
Python2 has default encoding as ascii which means
that is likely that some print() commands would
fails with UnicodeEncodeError.

This hack changes default encoding in order to
avoid such errors.

Change-Id: I4e21e6e32d4bb815693b7d6ce35efb6a5cca2fc2
2018-11-09 10:18:54 +00:00
Fabio Porcedda
c243d80af9 As suggested by pep8 don't compare boolean values or empty sequences
Refactoring to improve code style as suggested by pep8.

- "rc" and "status" variables cannot be None beacause the process is
  terminated after the "run_command_status"

- It's better to ignore an empty "username"

Change-Id: I8a34f4ab9e05d91786ce6d62e4db96811787b633
2018-11-07 12:16:58 +00:00
Ilya Etingof
d94e3a3431 Improve exit code implementation
Unnecessary dynamic GitReviewException.EXIT_CODE attribute
lookup refactored into static to benefit static analyzers.

Default process exit code changed from 127 (command not found error)
to 1 (general error)

Change-Id: I1fcb583a740bf32c4427a587e208d099712a7bc4
2018-11-06 12:26:11 +00:00
Stephen Finucane
7a660253f1 docs: Call out use of an agent to store SSH passwords
This is included as a note on the usage page for want of a better place
to put it.

Change-Id: I647cc8239e04e1f064aef3e0942ca94b0d5b4025
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Story: 2000431
Task: 2663
2018-10-24 15:27:48 +01:00
Stephen Finucane
af955c932e Don't set topic when submitting no-topic patches
Change-Id: I8f8880791ad7e46fb9e18623ab8bd295457424b2
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2018-10-16 15:13:07 +01:00
Stephen Finucane
03768832c4 Remove auto-branch name
The feature to configure branch names based on the presence of "bug",
"lp", "blueprint" or "bp" in the commit message is overly elaborate and
very OpenStack specific. Even with this, it hasn't been updated to keep
up with the times as many projects have migrated to Storyboard, which
isn't handled here.

Given that it frequently does the wrong thing and likely doesn't apply
to anyone outside of the OpenStack ecosystem, the wisest thing it to
simply remove the feature. This is a break in behavior but it seems
better than adding yet another flag for something that many users will
want enabled by default.

Change-Id: I82ecc1719de5c87d59bbfe73a042917e6559da1e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Story: 1130330
Task: 566
Story: 2001247
Task: 5777
2018-10-16 09:53:40 +01:00
Stephen Finucane
197a2de8a7 tox: Remove dead settings/targets
The sdist target is useless given that releases are automated.
Similarly, the '[testenv] install_command' uses the default value and is
therefore not required. Finally, some other things were slightly off or
otherwise annoying and can be fixed.

Change-Id: Ia029aba9ee5bc79cf39043a5fcaf9463aa1518f7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2018-10-15 15:02:27 +01:00
Stephen Finucane
f4b46e56be docs: Misc updates
I tried splitting these into separate commits but the splits were too
abstract.

Change-Id: I996c920e861d7507d0d0bb41ba4f5e65362e0b44
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Story: 1388398
Task: 584
2018-10-15 15:01:16 +01:00
Pete Zaitcev
56779ebe21 Clean up vestigal scripting in cmd.py
This was brought up by an RPM lint checker. It complaned about
a non-script being executable. Apparently the shebang was not
removed when we went all PBR.

Change-Id: I60098f334d136fe98d3492a3578516310e31296c
1.27.1.0a1
2018-09-19 17:39:18 +00:00
Zuul
185fb8da38 Merge "Fix compare_review's use of fetch_review" 1.27.0 2018-09-19 17:34:42 +00:00
Zuul
f6260701fa Merge "Use new %topic=XXXX syntax for topic pushes" 2018-09-19 17:09:43 +00:00
Clark Boylan
3c46c33ec0 Fix compare_review's use of fetch_review
fetch_review was updated to take project config information so that
projects hosted over http below some root (eg
https://gerrit.org/gerrit/here) could be properly fetched against. But
in adding this we broke the compare_review functionality which is the
other user of fetch_review.

Fix this by passing project config info into compare_review so that it
can pass that along to fetch_review.

Additionally we need to compare like types when looking at patchset
numbers so coerce them to ints when comparing.

Change-Id: I98fbf31821dc3a9162700725dec07bc7685ea5ca
2018-09-18 21:50:20 +01:00
Steve Kowalik
6587639df2 Always print failure case when testing remotes
Rather than requiring verbose to be specified when testing remote URLs,
always print the failure case to allow easier debugging, for example,
with unsigned CLAs.

Change-Id: I37e2d8b6b70a573a4a3f9091205d31100e3bf9f2
2018-09-14 15:28:43 -06:00
Han-Wen Nienhuys
dcbfb32b05 Use new %topic=XXXX syntax for topic pushes
The old syntax is undocumented and slated to be removed.

Uniformize handling of % options. Previously, combining options could
yield destination refs that look like

   refs/for/BRANCH%wip%private

which tries to switch on a non-existent option "wip%private".

Change-Id: Ia4e97eafbf685fcba78d95370dae08254a2c718b
2018-09-13 07:03:56 +00:00
Zuul
51ab58f3fb Merge "Start using reno for releasenotes" 2018-08-29 05:03:20 +00:00
Zuul
5bcb051915 Merge "Use doc/requirements and openstackdocstheme" 2018-08-29 05:03:19 +00:00
Monty Taylor
c7436f95c9 Start using reno for releasenotes
It's probably a good idea to be specific about what's changing in reno
releases.

Since reno support wasn't in tree we didn't pick up notes for these two
changes, but they're things users might want to know about.

Change-Id: I249a3a4d0cf378b60bf43ce65d49416879d5517e
2018-08-28 15:13:05 -07:00
Monty Taylor
8236cdbf37 Use doc/requirements and openstackdocstheme
oslosphinx is the old hotness. openstackdocstheme is the new hotness.
Also, we can use doc/requirements.txt for docs requirements.

Change-Id: I9cbc670c8fb065d240251f061919479c87193ff5
2018-08-28 15:13:00 -07:00
Zuul
ea82a1598b Merge "Testing getting specific patchset" 2018-08-22 02:21:04 +00:00
Zuul
f561bf3ff4 Merge "work-in-progress and private workflow in Gerrit 2.15" 2018-08-20 18:10:20 +00:00
Zuul
9bf76f87b3 Merge "Update tox docs environment to use sphinx-build" 2018-08-20 17:03:55 +00:00
Zuul
bc6ae5412c Merge "Document usepushurl in the man page" 2018-08-20 16:56:57 +00:00
Monty Taylor
c9282ae021
Update tox docs environment to use sphinx-build
We've been moving to running sphinx-build directly instead of python
setup.py build_sphin.

Change-Id: Ic847b5911aa7499033e879ffe6c1cac4d9c9f80e
2018-08-20 10:38:15 -05:00
Zuul
59c771d7cb Merge "support review URLs as download arguments" 2018-08-20 15:31:29 +00:00
Zuul
211eb98a2a Merge "Fix git review -d M,N with later gerrit" 2018-08-20 15:26:01 +00:00
Derek Waldner
694f532ca8 Update default gerrit namespace
According to latest Gerrit documentation, 2.15.3, refs/for/'branch'
should be used when pushing changes to Gerrit. Change the default
behavior to refs/for/* instead of refs/publish/* which has been
deprecated. This removes a warning from Gerrit remotes running the
latest version when pushing changes without commandline options.

Change-Id: Ibaddfda96457a72c54ca9c91a8ad25d14b88c582
2018-08-16 13:21:55 +00:00
Sorin Sbarnea
de0d27144e
tox: default envlist to supported python versions
- Removes py26,py32,py33 due EOL
- Added missing py36,py36,py37

Change-Id: I365c11decab680d3c7d3bfdd1b7328cb7efb3a1a
2018-07-17 14:50:32 +01:00
Doug Hellmann
7de9ffc933 support review URLs as download arguments
Rather than forcing users to copy only part of a URL to a review, allow
them to paste the whole URL and then parse it for them to find the
change id.

Change-Id: Ic012c86b2b477d17354bf8d119e1d4b698378dd7
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-06-13 22:09:10 +01:00
Doug Hellmann
ed3c79e452 expand help for --download option
Show the syntax for requesting a specific version of a patch.

Change-Id: Id72935c715a7b5c17722400dde6175b99e61860b
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-04-25 11:41:49 -04:00
Abbas Yazdanpanah
6f50b591db work-in-progress and private workflow in Gerrit 2.15
In Gerrit 2.15 two new workflow states(`work-in-progress` and
`private`) are introduced. This patch tries to implement them.

Gerrit documentation says:

To push a private change or to turn a change private on push the private
 option can be specified:

  git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%private

Omitting the private option when pushing updates to a private change
doesn’t make change non-private again. To remove the private flag from a
 change on push, explicitly specify the remove-private option:

  git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%remove-private

To push a wip change or to turn a change to wip the work-in-progress
(or wip) option can be specified:

  git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%wip

Omitting the wip option when pushing updates to a wip change doesn’t
make change ready again. To remove the wip flag from a change on push,
 explicitly specify the ready option:

  git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%ready

https://gerrit-documentation.storage.googleapis.com/Documentation/2.15/intro-user.html#private-changes
https://gerrit-documentation.storage.googleapis.com/Documentation/2.15/intro-user.html#wip

Change-Id: Ia093e4a691fa8eb17c798473a79a97694202fd03
2018-04-22 18:41:01 +04:30
Monty Taylor
31c5e0b081
Document usepushurl in the man page
usepushurl is a great setting - it reduces the number of actions git has
to do for things like a bare 'git fetch'. It is, unfortunately, not
documented in the manpage.

Change-Id: Ia7b179c6fcf6490454087aa359d891d1ff3af1a0
2018-03-22 07:04:14 -05:00
Thomas Hisch
aeeff97487 Fix git review -d M,N with later gerrit
It seems the "number" field returned via gerrit JSON can be a string
(2.13) or a integer (~2.14).  Ensure we can handle both.

Change-Id: I3cbda6c07343332aba592bd96fd8545f08a2cbfe
2018-03-13 20:36:34 +11:00