Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShowPatchAction.py : Make patches better readable #5997

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PrajwalM2212
Copy link
Member

Print better diffs showing a few context lines

Closes #5480

For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!

Checklist

  • I read the commit guidelines and I've followed
    them.
  • I ran coala over my code locally. (All commits have to pass
    individually.
    It is not sufficient to have "fixup commits" on your PR,
    our bot will still report the issues for the previous commit.) You will
    likely receive a lot of bot comments and build failures if coala does not
    pass on every single commit!

After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.

Please consider helping us by reviewing other peoples pull requests as well:

The more you review, the more your score will grow at coala.io and we will
review your PRs faster!

@PrajwalM2212
Copy link
Member Author

PrajwalM2212 commented Mar 3, 2019

Before the changes,
screen shot 2019-03-03 at 5 42 15 pm

Context lines are now displayed.
screen shot 2019-03-03 at 9 20 32 am

@PrajwalM2212
Copy link
Member Author

PrajwalM2212 commented Mar 3, 2019

The printing of the patch was handled by print_beautified_diff . This function took difflib.unified_diff as its input. But difflib.unified_diff had n=3 which is the default number of context lines that will be supplied.

The print_beautified_diff took care of printing the affected lines but it did not print the normal context lines.

@@ -48,6 +48,8 @@ def print_beautified_diff(difflines, printer):
color='red')
current_line_subtracted += 1
else:
printer.print(format_line(line[1:],
real_nr=current_line_added))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt whether we should only use current_line_added. The way GitHub uses to print the line number is to provide both current_line_subtracted and current_line_added for unchanged lines.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2019-03-09 at 1 42 29 PM

@li-boxuan Is this okay ? I think this is close to how GitHub prints.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me 👍. @Makman2 what's your view on it?

@PrajwalM2212 PrajwalM2212 force-pushed the context_lines branch 3 times, most recently from d3b7ce1 to a0b75fa Compare March 10, 2019 02:15
Print better diffs showing a few context lines

Closes coala#5480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

ShowPatchAction: Make patches better readable
4 participants