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

Hide expected Git errors from stderr #159

Merged
merged 7 commits into from
Jul 30, 2021
Merged

Hide expected Git errors from stderr #159

merged 7 commits into from
Jul 30, 2021

Conversation

akaihola
Copy link
Owner

Fixes #85.

With e.g. darker --revision=master..., newly created files would cause this Git error to appear on stderr:

fatal: Path 'newfile.py' exists on disk, but not in 'master'.

We already caught that situation and interpreted it properly as caused by a newly created file. In addition, the Git error messages are now silenced, but other Git errors are still logged with the ERROR loglevel.

Unfortunately I couldn't find a way to create a failing test, i.e. one that would be able to catch Git's stderr.

@akaihola akaihola added the enhancement New feature or request label Jul 11, 2021
@akaihola akaihola added this to the 1.3.0 milestone Jul 11, 2021
@akaihola akaihola self-assigned this Jul 11, 2021
@akaihola
Copy link
Owner Author

@casio would you be interested to review this PR? I invited you as collaborator in this project in case you would.

akaihola added 2 commits July 30, 2021 23:16
Different Git versions use either `Path does not exist` or `path does not
exist`
@sourcery-ai
Copy link

sourcery-ai bot commented Jul 30, 2021

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 1.97%.

Quality metrics Before After Change
Complexity 2.15 ⭐ 2.31 ⭐ 0.16 👎
Method Length 78.31 🙂 82.07 🙂 3.76 👎
Working memory 6.70 🙂 7.36 🙂 0.66 👎
Quality 75.59% 73.62% 🙂 -1.97% 👎
Other metrics Before After Change
Lines 668 738 70
Changed files Quality Before Quality After Quality Change
src/darker/git.py 75.65% ⭐ 73.68% 🙂 -1.97% 👎
src/darker/tests/test_git.py 75.55% ⭐ 73.59% 🙂 -1.96% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
src/darker/tests/test_git.py test_git_check_output_lines_stderr_and_log 0 ⭐ 153 😞 15 😞 54.73% 🙂 Try splitting into smaller methods. Extract out complex expressions
src/darker/tests/test_git.py test_git_get_modified_files 4 ⭐ 215 ⛔ 8 🙂 57.62% 🙂 Try splitting into smaller methods
src/darker/git.py git_get_modified_files 6 ⭐ 134 😞 9 🙂 60.82% 🙂 Try splitting into smaller methods
src/darker/tests/test_git.py test_git_check_output_lines 2 ⭐ 154 😞 9 🙂 62.56% 🙂 Try splitting into smaller methods
src/darker/tests/test_git.py test_git_get_content_at_revision 2 ⭐ 152 😞 9 🙂 62.77% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@akaihola akaihola merged commit 508a6ec into master Jul 30, 2021
@akaihola akaihola deleted the hide-git-error branch July 30, 2021 20:43
@flying-sheep
Copy link
Collaborator

Hi, you forgot to set a language for running git.

If you want to parse the localized output of some tool, you need to select a localization.

@akaihola
Copy link
Owner Author

akaihola commented Sep 1, 2021

@flying-sheep, that's an excellent catch! Could you please open a separate issue about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

Handling untracked files
2 participants