1111from collections .abc import Sequence
1212
1313from dfetch .log import get_logger
14+ from dfetch .manifest .manifest import Manifest
1415from dfetch .manifest .project import ProjectEntry
1516from dfetch .project .gitsubproject import GitSubProject
1617from dfetch .project .subproject import SubProject
2526class GitSuperProject (SuperProject ):
2627 """A git specific superproject."""
2728
29+ def __init__ (self , manifest : Manifest , root_directory : pathlib .Path ) -> None :
30+ """Create a Git Super project."""
31+ super ().__init__ (manifest , root_directory )
32+ self ._repo = GitLocalRepo (root_directory )
33+
2834 @staticmethod
2935 def check (path : str | pathlib .Path ) -> bool :
3036 """Check if this path is of the matching VCS."""
@@ -51,7 +57,7 @@ def has_local_changes_in_dir(self, path: str) -> bool:
5157
5258 def get_username (self ) -> str :
5359 """Get the username of the superproject VCS."""
54- username = GitLocalRepo ( self .root_directory ) .get_username ()
60+ username = self ._repo .get_username ()
5561
5662 if username :
5763 return username
@@ -60,15 +66,15 @@ def get_username(self) -> str:
6066
6167 def get_useremail (self ) -> str :
6268 """Get the user email of the superproject VCS."""
63- email = GitLocalRepo ( self .root_directory ) .get_useremail ()
69+ email = self ._repo .get_useremail ()
6470
6571 if email :
6672 return email
6773 return self ._get_useremail_fallback ()
6874
6975 def get_file_revision (self , path : str | pathlib .Path ) -> str :
7076 """Get the revision of the given file."""
71- return str (GitLocalRepo ( self .root_directory ) .get_last_file_hash (str (path )))
77+ return str (self ._repo .get_last_file_hash (str (path )))
7278
7379 @staticmethod
7480 def import_projects () -> Sequence [ProjectEntry ]:
@@ -131,7 +137,7 @@ def diff(
131137 if diff_since_revision :
132138 combined_diff += [diff_since_revision ]
133139
134- untracked_files_patch = str ( local_repo .untracked_files_patch (ignore ) )
140+ untracked_files_patch = local_repo .untracked_files_patch (ignore )
135141 if untracked_files_patch :
136142 if reverse :
137143 reversed_patch = reverse_patch (untracked_files_patch .encode ("utf-8" ))
0 commit comments