Explorar el Código

Replace porcelain usage in test_lfs.py with lower-level APIs

Jelmer Vernooij hace 1 semana
padre
commit
76b4582621
Se han modificado 2 ficheros con 25 adiciones y 7 borrados
  1. 25 6
      tests/test_lfs.py
  2. 0 1
      tests/test_source.py

+ 25 - 6
tests/test_lfs.py

@@ -27,7 +27,7 @@ import shutil
 import tempfile
 from pathlib import Path
 
-from dulwich import porcelain
+from dulwich.client import LocalGitClient
 from dulwich.lfs import LFSFilterDriver, LFSPointer, LFSStore
 from dulwich.repo import Repo
 
@@ -362,13 +362,23 @@ class LFSIntegrationTests(TestCase):
             f.write(pointer.to_bytes())
 
         # Commit files
-        porcelain.add(source_repo, paths=[".gitattributes", "test.bin"])
-        porcelain.commit(source_repo, message=b"Add LFS tracked file")
+        source_worktree = source_repo.get_worktree()
+        source_worktree.stage([b".gitattributes", b"test.bin"])
+        source_worktree.commit(
+            message=b"Add LFS tracked file",
+            committer=b"Test <test@example.com>",
+            author=b"Test <test@example.com>",
+            commit_timestamp=1000000000,
+            author_timestamp=1000000000,
+            commit_timezone=0,
+            author_timezone=0,
+        )
         source_repo.close()
 
         # Clone the repository
         target_dir = os.path.join(self.test_dir, "target")
-        target_repo = porcelain.clone(source_dir, target_dir)
+        client = LocalGitClient()
+        target_repo = client.clone(source_dir, target_dir)
 
         # Verify no LFS commands in config
         target_config = target_repo.get_config_stack()
@@ -410,8 +420,17 @@ class LFSIntegrationTests(TestCase):
             f.write(pointer.to_bytes())
 
         # Commit
-        porcelain.add(self.repo, paths=[".gitattributes", "data.dat"])
-        porcelain.commit(self.repo, message=b"Add LFS file")
+        worktree = self.repo.get_worktree()
+        worktree.stage([b".gitattributes", b"data.dat"])
+        worktree.commit(
+            message=b"Add LFS file",
+            committer=b"Test <test@example.com>",
+            author=b"Test <test@example.com>",
+            commit_timestamp=1000000000,
+            author_timestamp=1000000000,
+            commit_timezone=0,
+            author_timezone=0,
+        )
 
         # Reset index to trigger checkout with filter
         self.repo.get_worktree().reset_index()

+ 0 - 1
tests/test_source.py

@@ -292,7 +292,6 @@ class SourceCodeComplianceTests(unittest.TestCase):
         allowed_files = {
             "tests/test_bisect.py",
             "tests/test_filters.py",
-            "tests/test_lfs.py",
             "tests/test_maintenance.py",
             "tests/test_mbox.py",
             "tests/test_rebase.py",