463 Commits

Author SHA1 Message Date
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
Ian Wienand
b07a524a29 Add bindep.txt
Add bindep.txt with java to get CI going again

Change-Id: I0583eeb928c1e303f27bae00c73a25df0030369c
2018-01-10 11:11:04 +11:00
Zuul
ad59206575 Merge "Add a note on Windows and Unicode" 1.26.0 2017-11-17 21:07:54 +00:00
Zuul
c0fefb845d Merge "Fix output printing with python3" 2017-11-17 21:07:53 +00:00
Zuul
493075ca16 Merge "Add a note about contribution priorities" 2017-11-17 20:50:56 +00:00
Jeremy Stanley
c1b6e647d9 Add a note about contribution priorities
It's been poorly documented so far that the current git-review
maintainers are avoiding addition of new features. Gerrit-based
change workflows are already confusing enough to new users, and
providing them with too many complex options risks making things
worse. This tool's goal is to do a few things well and simply in
support of an opinionated workflow, without becoming everything to
everyone.

Since git-review sees broad usage outside the OpenStack contributor
community, it is subject to a lot of drive-by feature additions. Add
a note to the contributing document indicating its maintainers
consider it to be mostly complete (modulo bug fixes, compatibility
improvements, adding test coverage), so that readers will consider
strongly whether their particular improvement is well suited to the
existing scope of the tool.

Change-Id: I11b9f898286b75177493af31e209c2853d78f245
2017-11-17 03:46:01 +00:00
Ian Wienand
2ee19d3526 Add a note on Windows and Unicode
Add a rough note on what we've discovered about Windows and Unicode.
tl;dr use Python 3.6+

Change-Id: I219cfca6cb9ad427a55a7a1821f9fe0a9cf632f3
2017-11-17 14:09:10 +11:00
Ian Wienand
bbea22f773 Fix output printing with python3
I'm not sure what print_safe_encoding is trying to do
(Ie834931a549175471af029a6ec4d5794543d8c92).

  print(str.encode(sys.stdout.encoding, 'replace'))

means that print() ends up getting a bytes-object encoded in the
output encoding.  Thus print() is then going to output this as raw
bytes... not only is unicode going to come out as "\x..\x.." etc, but
even newlines get squished and you end up with stuff like

  $ /tmp/gitreview3/bin/git-review
  b'remote: \rremote: Processing changes: updated: 1, refs: 1\rremote: Processing changes: updated: 1,

I think this problem stems from not ensuring that incoming data
(output of git) is encoded as a string.  By setting
universal_newlines=True in run_command_status() we automatically
ensure that any incoming data is a unicode str, not bytes.

The final section, with the message about rhbz#1058167, appears to be
related to running git under an alternative locale where it's output
is translated.  I1bf1124f0b09d6658a7b0703e3b9e74ed80f4eea changed
things to run the commands under C locale, so there shouldn't be
unicode in here I wouldn't think.  But, by ensuring it's just a
string, we can print() it safely anyway.

Change-Id: I596dcba317ecfbaf437cb72d9850580ed6765fce
2017-11-17 09:33:39 +11:00
Clark Boylan
f918bf76d2 Handle http queries below /
Previously git review could not properly query Gerrit servers via http
if the root of the Gerrit api was below /. This is because it was always
rooting the changes query api at /changes instead of /foo/changes if
hosted at /foo.

To fix this we read the project name from the config so that we can
remove the project name suffix from the urls then append changes/ to the
resulting url to get a properly rooted query url.

Note this was never a problem with ssh because ssh can't be hosted as
some subpath. Everything is rooted with ssh and gerrit.

Change-Id: I46e21dfdbbb7f60aa89a7b028501c0d953ae1d7f
2017-11-15 17:37:11 -08:00
Zuul
ef47e1f553 Merge "Support git 2.15 and newer" 2017-11-15 04:32:14 +00:00
Zuul
3686e0967c Merge "show the config value result after fetching it in verbose mode" 2017-11-15 03:58:08 +00:00
Clark Boylan
d3d66a4715 Support git 2.15 and newer
The 2.15 release of git drops support for `git branch --set-upstream`
and replaces it with `git branch --set-upstream-to` which was added in
git 1.8. Move from --set-upstream to --set-upstream-to in order to
support git 2.15 and beyond. Note that this specifically affects the
`git review -d` functionality as it is what needs to update the
upstream.

This does drop support for git 1.7 and older though as this option did
not exist then. Polling linux distros and OS X the oldest git I can find
is on CentOS 7 which has 1.8 so this should be fine.

Story: 2001266
Co-Authored-By: Harry Mallon <Harry.Mallon@codex.online>
Change-Id: I5ded1ab39bb2c76bdc38655299bac11b4584e138
2017-11-05 15:26:18 -08:00
Doug Hellmann
84511b1124 show the config value result after fetching it in verbose mode
We show the command used to retrieve the config value, but don't show
what we find. Fix that, and also show cases where we are going to use
the default setting.

Change-Id: I53ee9ea6e3af4e951587c0845c8333874238f0c2
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-10-19 18:27:19 -04:00
Daniel Lublin
54ca2e399c Actually output the warning
Change-Id: If47f0be53e4b80eae9f03e48acb299c686984d95
2017-08-10 09:12:18 +00:00
Christoph Settgast
b61f5b2ec9 Fix listing changes over SSH for 2.14
The SSH query API changed from 2.13 to 2.14 from

{"number":"1", ...}

to

{"number":1, ...}

so we need to stringify everything in order to do len, encode etc. on
it.

Change-Id: I06bdd1b4b1181d00a27ce1e76f97baed8cde1284
Story: 2001095
2017-07-25 08:53:48 +02:00
Jenkins
089e8e64b1 Merge "Refactor displaying of reviews" 2017-07-21 16:05:47 +00:00
Jenkins
b3e0cac1aa Merge "Added topic field to the list output" 2017-07-21 16:04:12 +00:00
Jenkins
54221b1075 Merge "Switch to string format to avoid interpolation issues" 2017-07-21 15:54:05 +00:00
Jenkins
50cb05db6a Merge "Provide link to MediaWiki platform specific page" 2017-05-16 04:48:40 +00:00
Ian Y. Choi
e6c8e644b2 Provide link to MediaWiki platform specific page
Provide a link to the MediaWiki page on git-review installation, which
provides details for a range of platforms, including Windows and OS
X/macOS.

Change-Id: If030fa7614a7cea33c2a55605a6f0d68751173ea
Story: #2000481
2017-05-16 14:20:10 +10:00
Sorin Sbarnea
72175104dd Better username detection for add_remote()
Change-Id: Ia083ec9d5f19bff4944080559672b5947d4e43ee
2017-02-23 15:42:51 +00:00
David Caro
60f46a5a65 Refactor displaying of reviews
Split the displaying of reviews into a separate class to make it easier
to alter the output and accommodate different display options.

Change-Id: I6007259686fc15ae21ae6843faa4ff7ad545cef1
2016-11-16 15:13:49 +00:00
David Caro
ef4711d695 Added topic field to the list output
Now you can pass multiple '-l' options like '-ll' and when doing so, it
will show also the topic of the patches

Change-Id: Iabc1107d66a17fde751f90d7fa33f15fe54c7f58
Signed-off-by: David Caro <dcaroest@redhat.com>
Co-Authored-By: Darragh Bailey <dbailey@hpe.com>
2016-11-16 15:13:46 +00:00
Darragh Bailey
efb5126e67 Switch to string format to avoid interpolation issues
Convert to using python format to align and interpolate values to
ensure the correct output on python 2 & 3 when dealing with unicode and
str.

Interpolating strings using encode into '%s' and subsequently
interpolating the results into a second string results in the output
printing embedded byte strings on python 3.

 $ git-review -l
 b'226894'  b'master'  b'Add pem key parameter (WIP)'
 b'199225'  b'master'  b'support urls as change-id input

Which occurs because after converting a string to unicode bytes, it was
then interpolated using '%s'.

Switching to using '.format()' method takes care of converting the
output to the correct string format for python 2 & 3 automatically.

Change-Id: Ia962d18bda34e0244fb05636a7be263045ecb256
2016-11-16 15:10:18 +00:00
Jenkins
67dbbc2e59 Merge "Set a default EXIT_CODE for GitReviewException" 2016-08-30 14:33:40 +00:00
Jenkins
051f37c1c8 Merge "Support git without git credential" 2016-08-30 14:33:35 +00:00
Jenkins
59f87fe3d6 Merge "Fix no_git_dir UnboundLocalError in except block" 2016-08-30 14:26:37 +00:00
Jenkins
535202f579 Merge "fix encoding issue on Windows" 2016-08-30 14:25:30 +00:00
Jenkins
58851ab314 Merge "Avoid AttributeError when raising raw GitReviewExceptions" 2016-08-30 14:25:10 +00:00
Jenkins
66da56d895 Merge "Remove worthless print" 2016-08-30 14:24:27 +00:00
Jenkins
8cdabbf90d Merge "Fix AttributeError when can not connect to Gerrit" 2016-08-30 14:22:34 +00:00
Jenkins
cc0fbc286e Merge "Add several missing options to the man page" 2016-08-30 14:22:29 +00:00
Jenkins
c2c3418ede Merge "Refactor Isolated Env to use in unit tests" 2016-08-30 14:22:23 +00:00
Jenkins
f747ca3d1f Merge "Set author and committer explicitly" 2016-08-30 14:09:28 +00:00
Jenkins
6b056e4d0b Merge "Use hash of test ID to pick Gerrit ports in tests" 2016-08-30 14:06:54 +00:00
Jenkins
9149685eea Merge "Remove discover from test-requirements" 2016-08-30 14:06:42 +00:00
Jenkins
3de21e4075 Merge "Remove argparse from requirements" 2016-08-26 16:15:11 +00:00
Darragh Bailey
817bdf3059 Refactor Isolated Env to use in unit tests
Refactor the setup of the Environment and base test directories to
allow the same settings to be applied to the unit tests.

Change-Id: I554b4aa4f07fe4230c11d3ae62a77acbd66e7d84
2016-08-15 18:04:30 +01:00
Darragh Bailey
d64f004bdb Set author and committer explicitly
With the isolated home area for the unit tests, either missing
GIT_COMMITTER_NAME and GIT_AUTHOR_NAME environment variables or failure
to set the user.name on the local repository config will cause tests to
fail with git complaining about needing to know who is performing the
commit.

Results in seeing the following error message:

  Stdout: *** Please tell me who you are.

  Run

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

Change-Id: I4b87b6df3f19260c180af9beed77daf53dc6a7cc
2016-08-15 17:51:30 +01:00
Yuriy Taraday
33081ce1d6 Use hash of test ID to pick Gerrit ports in tests
This eliminates need for 127.* IPs mapped to loopback interface (which
is true only for Linux) and makes test site generation even more
predictable (name of site dir for a test is the same on any machine).

Hash function used is md5(test_id) % 10000 which is enough for now. This
function is checked for collisions before every run in tox.ini, so if
someone happens to add test that will cause a collision, it'll be
immediately visible. Hash function can be changed to anything else that
maps test ID string to a number in [0,10000].

Change-Id: Ib05d9b489a80e4f55c84db2f8bea20b88e959649
2016-08-15 17:41:30 +01:00
Zane Bitter
cf4e7cdb5f Clarify that submitting multiple commits is OK
I've heard feedback that the message that appears when you send multiple
commits for the review appears to imply that Gerrit cannot handle
multiple patches in a series, and that users should avoid submitting
them in favour of squashing all of their patches before submission. Of
course nothing could be further from the truth, and Gerrit's ability to
gracefully handle patch series is one of its major advantages over other
code review tools.

This changes the message to clarify that multiple self-contained patches
are perfectly OK.

Change-Id: Ia659149ce9332909b4bdbf09a2817a2015ebafd2
2016-08-12 11:36:05 -04:00
Swapnil Kulkarni (coolsvap)
7e9b63f418 Remove discover from test-requirements
It's only needed for python < 2.7 which is not supported

Change-Id: I5adfe5ccc0f64c8788a8e985f40c9450a599bd0e
2016-07-22 04:54:22 +00:00
Clark Boylan
c99d3a4f2b Install bc libs when running testsuite
Newer openssh clients refuse to connect to Gerrit when it doesn't have
bouncy castle libs installed bceause the available encryption methods
are not secure. Fix this by installing the bc libs making ssh clients
happy.

Note that this changes the war to one with working bouncy castle package
urls, it also reindexes after init to make this new war happy.

Change-Id: I1c5db09c53a56ffd856da24decf29566e86f9d87
2016-07-13 15:44:48 -07:00
Jenkins
69e240352a Merge "Update gerrit version for testing" 2016-07-12 00:10:42 +00:00
Pete Zaitcev
c4e25e5539 Add several missing options to the man page
The bulk of this patch is based on suggestions by Robert P.J. Day,
as found here:
  https://bugzilla.redhat.com/show_bug.cgi?id=1266468

Change-Id: I6411adec228950623a3cc1269701d47df38e8e62
2016-06-29 16:05:45 -06:00
Lukas Bednar
9ebdef990d Fix AttributeError when can not connect to Gerrit
Change-Id: I0c29bc29b9364c8203184a4dedc397e71e7ed437
Story: #2000586
2016-06-15 17:56:59 +02:00
Julien Danjou
652b8cb04c Set a default EXIT_CODE for GitReviewException
This should avoid:

  Could not connect to gerrit at ssh://some random string I typed@review.openstack.org:29418/openstack/repo.git
  Traceback (most recent call last):
    File "/usr/local/bin/git-review", line 11, in <module>
      sys.exit(main())
    File "/usr/local/lib/python2.7/site-packages/git_review/cmd.py", line 1534, in main
      sys.exit(e.EXIT_CODE)
  AttributeError: 'GitReviewException' object has no attribute 'EXIT_CODE'

Change-Id: I288dadd7bb2cc2766fb719171e2f0303aa250171
2016-06-14 11:45:01 +02:00
Jeremy Stanley
6eee79466a Use consistent formatting for deprecations
Add a warn() function for use in consistently displaying warning
messages, for use in things like deprecation warnings. Also make the
one current deprecation warning use this and be more explicit about
future removal.

Change-Id: I423524b30233ae45fbc04133566acf7a23828036
2016-06-07 14:44:51 +00:00
Frederic Lepied
47cbee9687 Fix git-review -d behavior with branches
- Fix fetch_review to use the information from the correct branch.
- Improve the unit test for git review -d to exercice the backport
workflow using branches.

Change-Id: I47c2e0149648a1f4f558e7f1ad6204f7f551865a
Closes-Bug: #2000294
2016-04-29 14:50:05 +00:00
Cedric Brandily
997c20bb37 Support git without git credential
Old versions (typically 1.7.9) of git don't provide git credential
subcommand but it's required in some cases by git-review over http(s).

This change updates git-review in order to handle correctly such case.

Change-Id: I6db5aca67818ae48f1d7d84bcdffff9c0e48767a
2016-04-18 19:26:55 +02:00