Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create FileModeBear #2370

Open
underyx opened this issue Mar 19, 2018 · 8 comments · May be fixed by #2912
Open

Create FileModeBear #2370

underyx opened this issue Mar 19, 2018 · 8 comments · May be fixed by #2912

Comments

@underyx
Copy link
Member

underyx commented Mar 19, 2018

It's really easy to forget to set +x on scripts. How about a bear like this:

[all.mode]
bears = FileModeBear
require = rw

[all.shell.mode]
bears = FileModeBear
require = rwx
@gitmate-bot
Copy link
Collaborator

GitMate.io thinks possibly related issues are #1583 (Create linterbear for Xquery), #973 (Create asciinemas), #161 (setuptools problem - creates requires.txt), #2079 (Create linter for gindent), and #839 (Create coala --bear-details <bear_name>).

@SubbulakshmiRS
Copy link

Is this Bear supposed to check whether if there is +x permission and if not add it as a patch ?Just checking

@jayvdb
Copy link
Member

jayvdb commented Jul 1, 2018

Is this Bear supposed to check whether if there is +x permission

Not quite that specific. It is supposed to check whether the file permissions match those given in the setting.

require isnt a good name for the setting, as it is rather ambiguous.

filemode = ... would be better.

However, the first design issue is how do we do this in a way that supports both Windows and Unix.
If you can come up with a sensible solution for that, we can assign the issue to you.

.. and if not add it as a patch

We currently do not have the ability for a 'patch' to modify file permissions.
A first version of this bear that only detects and does not fix would be good.
We could then create a new issue for fixing the problem automatically.

@jayvdb
Copy link
Member

jayvdb commented Jul 1, 2018

fyi, passwords and such are not appropriate for fixes; the bear would try to change the permissions if it can, otherwise it would not fix. bears escalating privilege levels, or having any access tokens, is not something we're likely to ever do.

If the person running coala wants a bear to do things which require escalated privileges, it should give the coala process those privileges.

Typically, the bear will be run by an account which has write access to the files.

But moreover, a 'fix' for modes can be done as a new 'action' type, but in this case a fix could be a patch as git patches do record changes of file modes. But coala doesnt support that yet iirc.

@RaiVaibhav
Copy link
Member

RaiVaibhav commented Jul 1, 2018

@jayvdb

However, the first design issue is how do we do this in a way that supports both Windows and Unix.

Confuses me does os module works differently in Windows ( srsly didn't know), if No then we have a
filename in bear arguments which is actually full file path, doesn't this will solve the caveats platform dependent?

@jayvdb
Copy link
Member

jayvdb commented Jul 1, 2018

https://docs.python.org/3/library/os.html mentions lots of OS specific aspects, and it links to https://github.com/python/cpython/blob/3.7/Lib/os.py which you can see is almost entirely OS specific logic.

Windows and Unix file permissions models are very different. Proper analysis is needed to ensure the bear would work correctly on both platforms.

Reading os.chmod would tell you that this has platform specific problems to it.

@jayvdb
Copy link
Member

jayvdb commented Nov 11, 2018

This issue reserved for Google Code-in task 6370456127930368.

@bkhanale
Copy link
Member

This issue is reserved under the GSoC project Improve Generic Bear Quality.

bkhanale added a commit to bkhanale/coala-bears that referenced this issue Jun 2, 2019
bkhanale added a commit to bkhanale/coala-bears that referenced this issue Jun 2, 2019
bkhanale added a commit to bkhanale/coala-bears that referenced this issue Jun 4, 2019
@bkhanale bkhanale linked a pull request Jun 4, 2019 that will close this issue
2 tasks
bkhanale added a commit to bkhanale/coala-bears that referenced this issue Jul 21, 2019
bkhanale added a commit to bkhanale/coala-bears that referenced this issue Jul 21, 2019
bkhanale added a commit to bkhanale/coala-bears that referenced this issue Jul 21, 2019
bkhanale added a commit to bkhanale/coala-bears that referenced this issue Jul 22, 2019
bkhanale added a commit to bkhanale/coala-bears that referenced this issue Aug 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

7 participants