#[non_exhaustive]pub enum ExecPolicy {
PythonCompat,
ModeBits,
}Expand description
How to decide whether a file is executable.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
PythonCompat
identify’s os.access(path, os.X_OK), so results match pre-commit:
- Unix:
access(2)semantics evaluated from the file’s mode, owner and group against the process’s real uid, gid and supplementary groups (queried once and cached): root needs anyxbit, the owner the user bit, group members the group bit, others the other bit. ACLs andnoexecmounts are not consulted. - Windows: every file is executable (
os.accessignoresX_OKthere), so every unknown-name file is checked for a shebang.
ModeBits
git’s notion of an executable file: the owner x bit
(mode & 0o100 != 0). This is the bit git add records as 100755
(git’s ce_permissions), so on Unix with core.fileMode=true the
result agrees with Meta::from_git_mode on the staged mode. Group
and other bits are ignored: 0o655 is not executable. Never
executable on non-Unix platforms.
For lefthook’s notion (“any x bit”) build the Meta by hand:
Meta::regular(mode & 0o111 != 0).
Implementations§
Source§impl ExecPolicy
impl ExecPolicy
Sourcepub fn is_executable(self, metadata: &Metadata) -> bool
pub fn is_executable(self, metadata: &Metadata) -> bool
Whether a regular file with this metadata counts as executable.
Trait Implementations§
Source§impl Clone for ExecPolicy
impl Clone for ExecPolicy
impl Copy for ExecPolicy
Source§impl Debug for ExecPolicy
impl Debug for ExecPolicy
Source§impl Default for ExecPolicy
impl Default for ExecPolicy
impl Eq for ExecPolicy
Source§impl Hash for ExecPolicy
impl Hash for ExecPolicy
Source§impl PartialEq for ExecPolicy
impl PartialEq for ExecPolicy
impl StructuralPartialEq for ExecPolicy
Auto Trait Implementations§
impl Freeze for ExecPolicy
impl RefUnwindSafe for ExecPolicy
impl Send for ExecPolicy
impl Sync for ExecPolicy
impl Unpin for ExecPolicy
impl UnsafeUnpin for ExecPolicy
impl UnwindSafe for ExecPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more