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

Handling untracked files #85

Closed
casio opened this issue Oct 30, 2020 · 1 comment · Fixed by #159
Closed

Handling untracked files #85

casio opened this issue Oct 30, 2020 · 1 comment · Fixed by #159
Assignees
Labels
enhancement New feature or request

Comments

@casio
Copy link

casio commented Oct 30, 2020

Using darker on a repo with as of yet untracked files raises eg.:
fatal: path 'new.py' exists on disk, but not in 'HEAD'

Steps to reproduce

$ mkdir /tmp/test
$ cd /tmp/test
$ git init
$ echo "print('legacy!')" > legacy.py
$ git add .
$ git commit -m 'initial commit'

$ echo "print('new stuff!')" > new.py
$ darker .
fatal: path 'new.py' exists on disk, but not in 'HEAD'

I guess this might be known and intended behavior, but it would be super useful if in a legacy codebase we could just use the same formatting/linting command also for new files added.

Are there any plans to support this usecase?

@akaihola
Copy link
Owner

Hi @casio, thanks for your well-written issue!

The error message fatal: path 'new.py' exists on disk, but not in 'HEAD' comes from Git when Darker runs

git show HEAD:./new.py

If you run darker -vv --diff . you'll see in more detail what happens behind the scenes. Darker will also output a diff of the reformattings instead of modifying the files, so it's easier to see that it actually still works despite the Git error.

It would probably be a good idea for Darker to look at Git output, and detect and suppress this particular message since it is in fact expected. Or what do you think?


By the way, there's also a somewhat related pull request #55 which fixes Darker when linter output refers to files which don't currently exist on disk.


As a side note, we have multiple pull requests which could use a review. Since current contributors are really busy, we'd appreciate help reviewing the PRs. Let me know if you're willing to join us!

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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants