google / yapf

A formatter for Python files
Apache License 2.0
13.78k stars 892 forks source link

Resolve duplicate pre-commit files? #1077

Closed hartwork closed 1 year ago

hartwork commented 1 year ago

Hi!

There are two pre-commit files in here that have identical copies as both .yaml and .yml:

# ls -l .pre-commit-* | sed "s,${USER},user,g"
-rw-r--r-- 1 user user 803 Apr 19 00:29 .pre-commit-config.yaml
-rw-r--r-- 1 user user 803 Apr 19 00:29 .pre-commit-config.yml
-rw-r--r-- 1 user user 239 Apr 19 00:29 .pre-commit-hooks.yaml
-rw-r--r-- 1 user user 239 Apr 19 00:29 .pre-commit-hooks.yml

# diff -u .pre-commit-config.y{a,}ml && echo identical
identical

# diff -u .pre-commit-hooks.y{a,}ml && echo identical
identical

Is there a reason we need both of these still today? Also, does anyone know what it was that got us into this duplication back then?

Thanks and best, Sebastian

bwendling commented 1 year ago

I'm not sure. The precommit stuff isn't my bailiwick. Someone with more knowledge should comment on this.

hartwork commented 1 year ago

@bwendling let me look into pre-commit code for that…

hartwork commented 1 year ago

@bwendling I believe it's fair to say that the .yml ones without a have never been supported by pre-commit.

Here's what I did with Git:

# git remote -v
origin  https://github.com/pre-commit/pre-commit (fetch)
origin  https://github.com/pre-commit/pre-commit (push)

# git rev-parse HEAD
51104fa94a6c3cdf603de2e187284289ea5abcf5

# git log -p | grep -F .pre-commit-hooks.yml | wc -l
0                                  ^^^^^

# git log -p | grep -F .pre-commit-hooks.yaml | wc -l
239                                       ^

# git log -p | grep -F .pre-commit-config.yml | wc -l
0                                  ^^^^^^

# git log -p | grep -F .pre-commit-config.yaml | wc -l
682                                        ^

# git log -p | grep -F "'yml'" | wc -l
0

# git log -p | grep -F '"yml"' | wc -l
0                      ^^

# git log -p | grep -F '".yml"' | wc -l
0                        ^

# git log -p | grep -F "'.yml'" | wc -l
0                      ^^

I'll create a pull request dropping the .yml ones then.