Skip to content

Conversation

@laanwj
Copy link
Member

@laanwj laanwj commented Apr 28, 2022

Improvements to the lint-files.py script:

  • Avoid use of shell=True.
  • Check the permissions in git's metadata instead of in the filesystem. This stops the umask or filesystem from interfering. It's also more efficient as it only needs a single call to git ls-files.

(what triggered this change was File "..." contains a shebang line, but has the file permission 775 instead of the expected executable permission 755. errors running the script locally).

Avoid the use of shell=True.
@laanwj laanwj added the Tests label Apr 28, 2022
@laanwj laanwj force-pushed the 2022-04-lint-permissions-git branch 2 times, most recently from c2661b5 to 9706c69 Compare April 28, 2022 11:39
Copy link
Member Author

@laanwj laanwj Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could put assert(0) here as well, as this is guaranteed to never happen. Git only stores an 'executable' bit, and its expanded permissions will always be 644 or 755. Then again, maybe future git might change this 😱

@laanwj laanwj force-pushed the 2022-04-lint-permissions-git branch from 9706c69 to 2feb6b6 Compare April 28, 2022 13:44
Copy link

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 48d2e80

@laanwj laanwj force-pushed the 2022-04-lint-permissions-git branch from 2feb6b6 to 91c78b1 Compare April 28, 2022 18:55
@fanquake
Copy link
Member

fanquake commented May 5, 2022

@vincenzopalazzo want to take another look here?

Copy link

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

ACK 48d2e80

Thanks to ping me @fanquake

@laanwj
Copy link
Member Author

laanwj commented May 9, 2022

ACK 48d2e80

Thanks! But that's the old commit 😄
Edit: wait, no, it's the first commit, 91c78b114ab2e0767e478caf33138147fa1dfff9 is the second and top one.

@willcl-ark
Copy link
Member

Found this PR after I wasn't able to run test-files.py locally. This patch does indeed fix it.

non-code review ACK.

I'm curious, how exactly does changing to 0o755 fix this? it somehow causes it to respect the default umask as it's now an octal number?

@laanwj
Copy link
Member Author

laanwj commented May 23, 2022

I'm curious, how exactly does changing to 0o755 fix this? it somehow causes it to respect the default umask as it's now an octal number?

No, that change is an ancillary change (representing octal numbers as decimal is just weird). The main change here is, as noted in the OP, that permissions are queried from git instead of the local filesystem.

Instead of using permissions from the local file system, which might
depend on the umask, directly check the permissions from git's metadata.
@laanwj laanwj force-pushed the 2022-04-lint-permissions-git branch from 91c78b1 to 908fb7e Compare May 23, 2022 09:09
@laanwj
Copy link
Member Author

laanwj commented May 23, 2022

Re-pushed 91c78b114ab2e0767e478caf33138147fa1dfff9 → 908fb7e2ec37fe68675d38dbfee4df9f861bb2b5

  • Use re.IGNORECASE for ALL_SOURCE_FILENAMES_REGEXP

Copy link

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok LGTM, sorry for the delay and for the error in the commit link

re-tACK 908fb7e

@maflcko maflcko merged commit fbb90c4 into bitcoin:master May 23, 2022
@bitcoin bitcoin locked and limited conversation to collaborators May 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants