question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

end-of-file-fixer add always a new line for .gitignore files

See original GitHub issue

describe your issue

After running pre-commit hook end-of-file-fixer it always add a new line for every .gitignore file in our private repo. Subsequently, our job checker always fails after run --all-files trying to fixes those files.

pre-commit --version

pre-commit 2.16.0

.pre-commit-config.yaml

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.1.0
    hooks:
      - id: end-of-file-fixer
      - id: trailing-whitespace
      - id: check-yaml
      - id: check-json

~/.cache/pre-commit/pre-commit.log (if present)

error information

An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', '-c', 'submodule.recurse=0', 'checkout', '--', '.')
return code: 2
expected return code: 0
stdout: (none)
stderr:
    
    This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout.
    
    
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pre_commit/error_handler.py", line 65, in error_handler
    yield
  File "/usr/local/lib/python3.8/dist-packages/pre_commit/main.py", line 396, in main
    return run(args.config, store, args)
  File "/usr/local/lib/python3.8/dist-packages/pre_commit/commands/run.py", line 399, in run
    exit_stack.enter_context(staged_files_only(store.directory))
  File "/usr/lib/python3.8/contextlib.py", line 425, in enter_context
    result = _cm_type.__enter__(cm)
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.8/dist-packages/pre_commit/staged_files_only.py", line 98, in staged_files_only
    with _intent_to_add_cleared(), _unstaged_changes_cleared(patch_dir):
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.8/dist-packages/pre_commit/staged_files_only.py", line 67, in _unstaged_changes_cleared
    cmd_output_b(*_CHECKOUT_CMD, env=no_checkout_env)
  File "/usr/local/lib/python3.8/dist-packages/pre_commit/util.py", line 154, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/usr/bin/git', '-c', 'submodule.recurse=0', 'checkout', '--', '.')
return code: 2
expected return code: 0
stdout: (none)
stderr:
    
    This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this 

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Jan 14, 2022

can you show the actual contents? perhaps add --show-diff-on-failure ?

0reactions
edgarribacommented, Jan 24, 2022

I’ll do — thanks in any case for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

generated .gitignore does not end in a newline #2456 - GitHub
Successfully merging a pull request may close this issue. added newlines at end of template gitignore files jmarca/phoenix. 2 participants.
Read more >
git - Apply .gitignore on an existing repository already tracking ...
I recently added a .gitignore file under my project and I assume that tells Git to ignore the files listed in the file....
Read more >
.gitignore file - ignoring files in Git | Atlassian Git Tutorial
Git ignore patterns are used to exclude certain files in your working directory from your Git history. They can be local, global, or...
Read more >
How to Use a .gitignore File - Pluralsight
A .gitignore file is a plain text file where each line contains a pattern for ... First, you have to add a setting...
Read more >
gitignore Documentation - Git
A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found