Skip to content

Remove control character stripping. #926

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

Merged
merged 3 commits into from
Sep 30, 2019

Conversation

uri-canva
Copy link
Contributor

The logic to strip away ansi control sequences only works if they're at the end of the line, if the control sequences are at the beginning of the line the whole line will be stripped away, and all progress information will be lost.

git/util.py Outdated
# END cut away invalid part
sline = sline.rstrip()
sline = self.re_ansi_escape.sub('', sline)
sline.strip()
Copy link
Member

Choose a reason for hiding this comment

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

strip() will not mutate the string. Thus it should be sline = sline.strip().
If it is important, do you think it's possible to have a test for it? Otherwise, maybe that line is not needed at all.

Copy link
Member

Choose a reason for hiding this comment

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

I just saw that the line stripping was done previously as well, let's just re-add it then as in sline = sline.rstrip(). Apparently there is no test that would need it, and it's tech-debt I wouldn't ask you to pay either 😅.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely, good catch!

Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

(Sorry, hit one-line comment by accident)

Thanks a lot for your contribution! I would love to merge it as soon as possible!

@codecov-io
Copy link

codecov-io commented Sep 28, 2019

Codecov Report

Merging #926 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #926   +/-   ##
=======================================
  Coverage   93.62%   93.62%           
=======================================
  Files          59       59           
  Lines        9800     9800           
=======================================
  Hits         9175     9175           
  Misses        625      625

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9121f62...7a5de47. Read the comment docs.

@uri-canva
Copy link
Contributor Author

Hmm, tests are failing, it is a bit different in behaviour, before if there was abc<control sequence>def the resulting string would be abc, now it's abcdef. Will have to test it further.

@uri-canva
Copy link
Contributor Author

Seems to have been a bad rebase on my part, now that it's rebased on master after the other PRs were merged it's working fine.

@uri-canva uri-canva requested a review from Byron September 29, 2019 00:52
Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

It looks like the strip() call is not yet reassigned, but looks great otherwise!
Thanks so much for your efforts!

git/util.py Outdated
# END cut away invalid part
line = line.rstrip()
line = self.re_ansi_escape.sub('', line)
line.strip()
Copy link
Member

Choose a reason for hiding this comment

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

Thank you! Once line = line.strip() is back I can merge it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I must have dropped the change during the rebasing. Because the tests only work on master I lose track of where the commits are sometimes. 😆

@uri-canva
Copy link
Contributor Author

Ah it's the stripping that breaks the tests.

@uri-canva
Copy link
Contributor Author

Changed it back to rstrip instead. I don't really understand what is going on, it works on my machine both in the macos host and the linux docker image with strip, so I couldn't debug it. I guess leaving it as it is is the safest option.

@Byron Byron merged commit bb8b383 into gitpython-developers:master Sep 30, 2019
@Byron
Copy link
Member

Byron commented Sep 30, 2019

Thanks so much for your continued efforts, it's much appreciated :)!

@uri-canva uri-canva deleted the control-characters branch September 30, 2019 05:01
@uri-canva
Copy link
Contributor Author

Thank you for the wonderful library!

@Byron
Copy link
Member

Byron commented Sep 30, 2019

About 10 years later, I am not quite sure if it's wonderful anymore ;).

Somehow now it breaks on master in a spot that seems unrelated. Fascinating. Could it be the difference between strip() and rstrip()?

@uri-canva
Copy link
Contributor Author

It does seem completely unrelated: it doesn't have anything to do with progress. I understand if it would break tests related to progress. But anyway definitely revert it if it's the problem!

@Byron
Copy link
Member

Byron commented Sep 30, 2019

It looks like the rstrip() call was the problem. Probably it should worry me that I have no idea how this could affect that particular test :/.
The conservative voice tells me to roll back the commit entirely, but prefer to trust the respective tests and rather add additional ones as needed.

@uri-canva
Copy link
Contributor Author

Yeah I think rolling back makes sense, then figure out how to repro the failure on the PR with a new test, then fix it. Without a new test that fails on the PR there's no way to tell if the problem will reappear after the PR is merged.

@Byron
Copy link
Member

Byron commented Sep 30, 2019

Thanks, @uri-canva , the respective commit was reverted.

I agree, probably it would be beneficial to have a test for the initial motivation of this PR, i.e. the code removing too much of the line if the escape sequence appears in an unexpected spot, and then provide a fix.

@uri-canva
Copy link
Contributor Author

Oh yes, that too. I meant it mostly the other way around: none of the tests failed on this PR, but then some tests failed on master, so it would be good for that hole to be filled.

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.

3 participants