pcdshub / pcdshub/pre-commit-hooks

Some hooks change EOL from CRLF to LF

Open
#38 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
12
Forks
13
Avg merge
7d 7h
Merged PRs (30d)
1

Description

Current Behavior

If a file was CRLF it will be changed to LF.

Expected Behavior

EOL should not be changed from the original file format

Context / environment

Steps to Reproduce (for bugs)

  1. Have a repo with a file ending in CRLF
  2. run e.g. pre-commit hook twincat-leading-tabs-remover on all files
  3. Check file ending of the file which is now

Suggested Solution

Adapt the hooks to clean the output with something like

with open(filename, "r", encoding="utf-8", newline="") as f:
    original = f.read()

eol = "\r\n" if "\r\n" in original else "\n"
fixed = original.replace("\r\n", "\n")  # normalize internally
fixed = do_your_thing(fixed)
fixed = fixed.replace("\n", eol)        # restore

with open(filename, "w", encoding="utf-8", newline="") as f:
    f.write(fixed)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with a CRLF file and the twincat-leading-tabs-remover pre-commit hook. Inspect the affected hook implementations and verify that processing preserves the input file's original EOL style; done means CRLF files remain CRLF while the hook's cleanup still occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.