From da6cb19c293c4998a5d8152b3660dc5e8d3b26e0 Mon Sep 17 00:00:00 2001 From: Mica White Date: Mon, 30 Mar 2026 20:42:35 -0400 Subject: Add check for executability --- src/lib.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 5a6b7df..0eeee6d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,6 +36,7 @@ use git2::{ Commit, FetchOptions, MergeOptions, Oid, PushOptions, Reference, RemoteCallbacks, Repository, Signature, Time, Tree, }; +use is_executable::is_executable; use serde::{Deserialize, Serialize}; use thiserror::Error; use uuid::Uuid; @@ -136,16 +137,17 @@ pub fn current_branch(repository: &Repository) -> Result { Ok(branch_name) } -pub fn filemode_for_dir_entry(metadata: &Metadata) -> i32 { - if metadata.is_dir() { +pub fn filemode_for_dir_entry(path: &Path) -> std::io::Result { + let metadata = path.metadata()?; + Ok(if metadata.is_dir() { 0o040000 } else if metadata.is_symlink() { 0o120000 - } else if metadata.permissions().readonly() { - 0o100644 - } else { + } else if is_executable(path) { 0o100755 - } + } else { + 0o100644 + }) } pub fn path_to_tree(repository: &Repository, path: &Path) -> Result { @@ -160,7 +162,7 @@ pub fn path_to_tree(repository: &Repository, path: &Path) -> Result