pre-commit-ci / issues

public issues for https://pre-commit.ci
16 stars 3 forks source link

[feature] Can pre-commit-ci robot respect file mode? #161

Closed Freed-Wu closed 1 year ago

Freed-Wu commented 1 year ago

I add a shebang to .pre-commit-config.yaml to allow me to replace pre-commit run -a with ./.pre-commit-config.yaml which is more easy to input (just press ./.p<TAB>).

#!/usr/bin/env -S pre-commit run -ac

However, pre-commit-ci changes the file mode x.

screen-2023-01-18-20-57-51

Can it respect the file mode? TIA!

asottile commented 1 year ago

that file should not be executable by convention

Freed-Wu commented 1 year ago

But, even if this file is not +x, the PR from pre-commit.ci still should respect the file mode, for example, if .pre-commit-config.yaml is rw-rw-rw-, the PR shouldn't change it to rw-r--r--, I think.

asottile commented 1 year ago

yes I understand, but you're doing something pretty weird and I don't want to write special code to support such a weird case when it's a common mistake to make the file executable

Freed-Wu commented 1 year ago

you're doing something pretty weird

I know. (A weird hack :smile:)

if .pre-commit-config.yaml is rw-rw-rw-, the PR shouldn't change it to rw-r--r--.

How about this? I think it is reasonable. Because in some situation, umask is not 022. We should not break it.

asottile commented 1 year ago

git doesn't store the rest of the umask -- git only has modes 0644 and 0755 -- it already isn't going to change 0666 to 0644 because that doesn't mean anything to git