Commit Graph

42 Commits

Author SHA1 Message Date
James E. Blair 64b8d6dc6c Handle binary data in diffs
Even though we won't usually display it, binary data may show up
in a diff.  We can't decode it to display it, so just replace it
with a placeholder string so we don't crash.

Change-Id: I4794e707745ed8315afec00c1981e239ec98ef0e
2020-02-20 09:45:34 -08:00
James E. Blair dfbe737cb9 Change some OpenStack to OpenDev or ttygroup
Change-Id: I1992146163b4a2ad9e70751c4ebd6b6a6663e441
2019-04-23 19:21:05 -07:00
James E. Blair cd2538e04a Fix tab expansion in inter-patchset diff
There are some lines which were being read as byte arrays and
were not decoded into strings which was causing them to bypass
tab expansion (because they caused an exception which was caught
and the un-expanded text was used instead).  Correct those cases
and disable the exception handler so that we can identify any
other cases by triggering a crash.

Change-Id: I4b34132290fc8611cc770d572068197b33c0789c
2019-03-28 08:03:42 -07:00
Dominique Martinet c4b7fc6e37 gitrepo DiffFile: convert tab to » + spaces
tabs are displayed as question mark by urwid, so need replacing.
While we are replacing, might as well mark them like in the web UI.

Ideally I would want to use a slightly different color for them,
but that would require to add many new colors in the config (context,
full new line, part of new line) and would not be very compatible
with 8-colors terminals -- the '»' character is hopefully rarely used
enough to be useable as is.

Change-Id: Ic974774bf546765fa5b3e9266aee8ff973865502
2019-03-19 09:04:44 -07:00
James E. Blair cb12ada037 Speed up loading change screen
If a change has many revisions, loading the change screen may be
slow because we verify the presence of each commit and its parent
individually.

Instead, do that in a batch to speed things up.

Change-Id: Ib4b1c34500b98b8bb7307a5aaca86802a15e635d
2017-08-24 13:18:33 -07:00
Masayuki Igawa fa378e224d Add trailing-whitespace style
This commit adds trailing-whitespace style for emphasizing. In gerrit,
we can find a trailing-whitespace very easily because it is emphasized
in red. So this commit imitates it.

Change-Id: Ie3f35c678093c51d8e39aeeaab2ea17d504e89fb
2016-09-21 13:50:23 +00:00
James E. Blair 6f68c58224 Handle ValueError on missing git commit
Apparently gitpython might now throw a ValueError on a missing commit.

Change-Id: I0e01fe569281afa4675e75c749b35de5afe47457
2016-05-11 11:34:53 -07:00
Jenkins 44fd26d781 Merge "Add config option for git clone URL" 2016-03-10 16:37:53 +00:00
Christoph Gysin 5479310d75 Add config option for git clone URL
This commit adds a new config option 'git-url', where the
base URL can be specified to anything recognised by git-clone:
https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS

This is useful if the values provided by gerrit are incorrect, or if
you have access to a gerrit mirror closer to you.

Change-Id: I35ee5540aad2f27125ec15e6e933ac1ad3f3050e
2016-03-09 13:11:59 -08:00
David Shrewsbury 06957db1ed Use diff long options and uncap GitPython
GitPython had a very incompatible change that breaks any call that
uses a single character option (e.g., -U) that requires no space
between the option and the value. So far, this breaks the diff API
where we used the -U option instead of the long option equivalent.
For history:

https://github.com/gitpython-developers/GitPython/issues/382

So far, I've only seen one place where this bites gertty. Since the
GitPython author has stated this will not be reverted or fixed, having
a permanent cap on that library seems harsh as we won't get any other
bug fixes.

This fixes the known/found areas where we are affected.

Change-Id: Iadb279234af2ea01fbff35dc629c01dae5a3195c
2016-03-08 14:09:28 -05:00
James E. Blair b33cbc0a7a Fix diff crash on perm-only changes
The update to GitPython that supports easily detecting the filenames
in file-permissions-only changes merged a year ago.  Start using it
and raise the mininum GitPython version to one which supports it.

Change-Id: I9a5104a4b399dee0d9e029fd0b10e37b8aafd3f8
2016-02-17 11:18:55 -08:00
James E. Blair f33d3bc234 Add another utf8 test change comment
This change has utf8 chars in the diff itself.

Change-Id: I4fb910e781fedb3e2830829d1bef7d0c1e12da0e
2016-02-10 08:07:14 -08:00
James E. Blair 8575905669 Fix unicode regression regressions
8377e0a went a bit too far and removed some code that was necessary
for 3.4 but broke some utf-8 in git commits.  This restores most
of what that removed, with one change that causes it to work with
the test commits listed at the top of the file.

Change-Id: Id39d7799f9c210a0ff0a80aeef34681eb6fe5770
2016-02-10 07:56:44 -08:00
Jan Kundrát 8377e0ac28 Fix unicode regressions
Commit 74877d2 added improved support for python3 but introduced
some regressions around unicode handling.

Inspired-By: James E. Blair <jeblair@linux.vnet.ibm.com>
Change-Id: I424a921d80959777ff72df499c5931a21dc0dccb
2016-02-05 15:54:34 -08:00
Jay Pipes 74877d2499 Allow gertty to run in Py3K environments
In environments without py27, gertty was unable to run. This patch
addresses all the Py3K issues discovered when getting gertty running in
a py34-only environment.

Change-Id: I32a06f9768bdeaf8e95ddf9a9e54c79059fbaa2f
2016-01-15 09:10:31 -08:00
David Stanek 0b16cbb8c4 Refactor: move getRepo out of the App object
The getRepo method really doesn't have much to do with the application
object. Since it's really a utiltiy method for dealing with git repos
I've moved it to gertty.gitrepo.

Change-Id: Ic3349430c456ee184bbf57b6e5b7de4f940b4cc1
2015-06-09 23:50:43 -04:00
James E. Blair 890a0892ef Fix diff display of deleted empty files
This case was not handled at all and caused a crash.

Also handle the case where a file present in the diff is not
present in the new commit while diffing between patchsets.

Change-Id: I24b54b6db7eae8d6c6c349ab6ed2bf846f104f86
2015-05-27 08:38:08 -07:00
James E. Blair 3c9124969b Add database pruning
By default, remove changes (and associated git refs) that have been
closed for more than 2 months.

Change-Id: I5d1176b13a7c0fdaf12e346537fd7e1251868461
2015-05-27 08:34:53 -07:00
James E. Blair c0cabc82f6 Attach comments to files
Since each revision now has files, associate comments with the
file relation rather than revisions so that the path is not stored
twice in the database.

Also correct a problem where comments could be left on empty files
or lines that are not in a file in the unified view.

The SQLAlchemy constraints API seems to have changed between
0.9.9 and 1.0.4.  Support both behaviors to be user-friendly even
though we now specify 1.0.4.

Change-Id: If6593d279a432ea8a48f4bd74a157e4978e69eaa
2015-05-27 08:34:04 -07:00
James E. Blair 6265622074 Sync change when missing refs
The logic to decide from where to fetch refs is getting complicated
and depends on the full repo url and ref.  This information can be
different for each revision of a change, but is only needed in the
rare case that a local repo was damaged or removed.  Rather than
storing all of this information in the database for what should be
a rare event, simply sync any changes that have missing refs and
use the normal code path for deciding where to fetch refs.

Change-Id: I4308db51b4847163b255686a62d5bad4e6226b4d
2015-04-06 07:47:23 -07:00
James E. Blair ac492e1580 Fix crashing on files with no changes
If a file only has mode differences, but no content difference,
we do not have access through GitPython to find out the filenames.

https://github.com/gitpython-developers/GitPython/pull/266 has
been submitted to correct that, but in the mean time, display
"Unknown File" to avoid crashing.

Change-Id: Ic935f9737ae3978a7a639408c24f166c76a2c999
Story: 2000027
2015-03-02 09:39:19 -08:00
Jeremy Stanley 480610506c Handle (ignore) binary file diffs
If git diff detects a binary file with differences, it might add
some (currently) unparseable text to the diff. Ignore it to avoid an
error.

Change-Id: Ib4f615e2f2bd8d633657949c8732556b4a0575c6
2015-01-23 18:55:52 +00:00
Jeremy Stanley 12edc3aaf9 Only decode email if already encoded
* gertty/gitrepo.py(CommitContext.decorateMessage): A regression was
introduced by 3e23dba where some platforms already used unicode for
the author.email and committer.email values. In those circumstances
attempting to decode from UTF-8 fails spectacularly, so now we only
decode when we need to.

Change-Id: I267a4cb7ff35a8c864a7f3396abd5bf44ecd1ffc
2015-01-16 19:36:41 +00:00
Jenkins 7d5b02d9af Merge "Have git not colorize output for diffs" 2014-09-05 20:10:00 +00:00
Monty Taylor f2aacf177a Have git not colorize output for diffs
We need more control over diff colorization for proper rendering
and processing. Ensure that local settings don't cause us to
blow up when we're doing it.

Change-Id: I07fc445d9328c9df1ed52e8b328cce6fbea78f43
2014-09-05 12:52:52 -07:00
James E. Blair 3e23dbad0f Handle unicode emails in git commits
This should probably never happen, but it has anyway, so assume the
email field is a utf8 string.  This should avoid crashing in case
someone has a utf8 email, but may not be a complete solution to
the case that an email is in a non-ascii, non-utf8 charset.

Change-Id: I95ed91e5fdfe35b73550e1824e609a0b1d388b3a
2014-09-05 09:25:05 -07:00
James E. Blair f47275022b Reduce impact of check revisions task
Now that change refs are stored locally, the only time a local repo
should be missing revisions is when it is newly cloned.  Handle the
case where a user deletes the local repo automatically (when gertty
starts and a repo does not exist for a subscribed project, perform
a missing refs check on that project).

If the user knows something is wrong, they can supply the
--fetch-missing-refs flag at startup and an exhaustive check will
be run of all projects.

Otherwise, do nothing.

Change-Id: Iedebbe4b05ec1293b82c651587e42004444dc4a8
2014-08-30 10:56:52 -07:00
James E. Blair 98f94be285 Fix crash on diff of new empty file
When adding (or presumably removing) an empty file, there is no
diff header, but that's where Gertty was getting the filenames.
Instead, get them from the git blob itself.

Change-Id: Ib2908aaf1d7554df53b5fb262017d85f3a560066
Story: 161
2014-08-18 15:38:08 -07:00
James E. Blair 9d215d4942 Fix newline warning overwriting final line
In the case that the final line of a file only had a newline
change, the line would be omitted from the old side of the diff.

Change-Id: I1e2e67fda4943ea38152a3ddd0004aa9210a9fa5
Story: 158
2014-08-17 11:05:15 -07:00
James E. Blair 473088474c Fix crash on comments from undisplayed files
If there is a comment on a file that would not otherwise be displayed
because there is no diff, create an all-context diff for that file
so the comment may be displayed.

Also, update the number of comment lines to be displayed in the
context expansion button ("Expand X lines of context").

Change-Id: I6db509b42032b282dbbfdbee0d639f97b8b70da3
2014-08-17 10:07:11 -07:00
Robert Collins 99aa6ddda3 Support comments in commits
Gerrit represents changes to commits with a file change of /COMMIT_MSG
and magically offset file comments :/. In this patch I reproduce that
logic sufficiently well to match up on all the commits I have looked
at.

Since diffs vs the base should not show the old commit's commit
message, I have hinted to the diff function when to include the commit
message in the output.

Change-Id: I8adb9fa22b384cace88f114f770a3eb5d3a89f5c
2014-07-12 20:23:29 -07:00
James E. Blair b459c93395 Handle missing commits
If gertty is interrupted when fetching commits, or, well, any number
of weird things happen to the git repo, we could end up not having
the needed commits locally.  Do a sanity check before opening a
change and fetch them if needed.

Change-Id: I9bbecd09d1820e405b51a8471c5fd9e4fe8a7841
2014-05-30 08:44:22 -07:00
James E. Blair 101cde8092 Handle (ignore) no-diff renames
If git diff detects a file rename with no changes, it might add
some (currently) unparseable text to the diff.  Ignore it to avoid
an error.

Change-Id: I3542e0dfd9d7c749510f0539066cfa0147e239a3
2014-05-30 08:44:22 -07:00
James E. Blair ee2df47b95 Add local cherry-pick button
Change-Id: I392b0ce4d672eaf0090018107cc9862f6f95fd50
2014-05-27 09:09:40 -07:00
James E. Blair e5666d006b Fix handling no newline at EOF in both files
If both files have no newline at EOF, diff will notify us in the
context, but that case wasn't handled by the parser.

https://storyboard.openstack.org/#!/story/84

Change-Id: Ib2f1b4b4c9d8f38a983300e7026331754592705f
2014-05-17 16:00:26 -04:00
James E. Blair 227b6a0add Expand context as needed to include all comments
Use methods that can be re-used to support manually expanding
context by the user.

Also fix a s/old/new/ typo bug.

Change-Id: I5b247204b959add9fbfd51af7e508d3d07b7c001
2014-05-04 13:32:28 -07:00
James E. Blair 067aa68dcd Process more diff output
This gets up to 10,000 lines of diff context information, but does
not display it.  Now we have the data and in a future change can
display more context if needed in order to show comments or if the
user requests it.

Change-Id: Id569732ffa40610f67bf479de8bf936580fbacf1
2014-05-03 17:42:37 -07:00
James E. Blair a44a82bff3 Refactor diff calculation to facilitate more context
Create groups of diff chunks and context chunks.  In a subsequent
change we can use that to better control the displayed context.

Change-Id: I75858d002e9a9fff809c91cfced81c6022d86196
2014-05-03 16:51:30 -07:00
James E. Blair 0a0ae71ea4 Handle file renames in diff view
Change-Id: I809a0bddc2ca45f9b5789abeb770cf55d068f87d
2014-04-30 13:29:47 -07:00
James E. Blair dfeef53895 Handle "No newline at end of file" and add --no-sync option
Change-Id: Ic40e4151eeacfd0514f5bdfb7eb268b0a08eb19b
2014-04-30 10:01:37 -07:00
James E. Blair 5585ba6786 Fix displaying new files
Change-Id: Idacb212482b33574ba71bf8f90b62b594616b77a
Closes-Task: some subtask of story 70
2014-04-29 18:19:36 -07:00
James E. Blair 1d6b0fd881 Initial commit
Change-Id: Ie79f257c46a2c50abdd7ce63bfeceaad976ca878
2014-04-29 16:28:49 -07:00