Selaa lähdekoodia

Add blob_from_path_and_mode call.

Jelmer Vernooij 4 vuotta sitten
vanhempi
commit
5924a8f9b0
1 muutettua tiedostoa jossa 13 lisäystä ja 2 poistoa
  1. 13 2
      dulwich/index.py

+ 13 - 2
dulwich/index.py

@@ -577,7 +577,7 @@ def build_index_from_tree(root_path, index_path, object_store, tree_id,
     index.write()
 
 
-def blob_from_path_and_stat(fs_path, st, tree_encoding='utf-8'):
+def blob_from_path_and_mode(fs_path, mode, tree_encoding='utf-8'):
     """Create a blob from a path and a stat object.
 
     Args:
@@ -587,7 +587,7 @@ def blob_from_path_and_stat(fs_path, st, tree_encoding='utf-8'):
     """
     assert isinstance(fs_path, bytes)
     blob = Blob()
-    if stat.S_ISLNK(st.st_mode):
+    if stat.S_ISLNK(mode):
         if sys.platform == 'win32':
             # os.readlink on Python3 on Windows requires a unicode string.
             fs_path = os.fsdecode(fs_path)
@@ -600,6 +600,17 @@ def blob_from_path_and_stat(fs_path, st, tree_encoding='utf-8'):
     return blob
 
 
+def blob_from_path_and_stat(fs_path, st, tree_encoding='utf-8'):
+    """Create a blob from a path and a stat object.
+
+    Args:
+      fs_path: Full file system path to file
+      st: A stat object
+    Returns: A `Blob` object
+    """
+    return blob_from_path_and_mode(fs_path, st.st_mode, tree_encoding)
+
+
 def read_submodule_head(path):
     """Read the head commit of a submodule.